title: Using 2 nested asynchronous threads - Android Java AutoCompleteTextView
body: <p>I've been working on creating a dynamic <code>AutoCompleteTextView</code>, and encountered a problem using two nested asynchronous threads.</p>
  
  <p>The first asynchronous thread is a <code>Filter</code>, and inside this thread I make HTTP calls asynchronously. That causes the filter to return empty <code>FilterResults</code> because Filter doesn't wait for asynchronous HTtP calls.</p>
  
  <p>To overcome this situation I used a flag, and used a while loop inside the filter just before the <code>return</code> line waiting for asynchronous HTTP calls to finish and set the flag. </p>
  
  <ul>
  <li><p>This worked fine, but is there a better solution? </p></li>
  <li><p>Can this approach lead to another problem that I can't see?</p></li>
  </ul>