title: Is publishProgress method of AsyncTask asynchronous?
body: <p>I've used <code>AsyncTask</code> quite a bit - but I have come across a seemingly simple question that confused me. The question is this: </p>
  
  <blockquote>
    <p>Is <code>publishProgress(Progress... values)</code> supposed to return
    immediately? In other words, is this method asynchronous?</p>
  </blockquote>
  
  <h1>Some Context:</h1>
  
  <p>I'm trying to determine whether the following code </p>
  
  <ul>
  <li>Fires an HTTP request every three seconds, regardless of the response <strong><em>OR</em></strong></li>
  <li>Fires an HTTP request, waits for the response, and <strong><em>then</em></strong> sleeps for three seconds before firing the next request.</li>
  </ul>
  
  <p>public class MyAsyncTask {</p>
  
  <pre><code>@Override
  protected void doInBackground(String... params) {
      while (mRunning) {
          // Call publishProgress
          this.publishProgress(makeHttpRequest());
  
          // Sleep for 3 seconds
          synchronized (lock) {
              try {
                  lock.wait(3 * 1000);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
          }
      }
  
      return null;
  }
  
  private HttpResponse makeHttpRequest() {
      HttpResponse ajaxResponse = null;
      Throwable throwable = null;
      try {
          ajaxResponse = mHttpClient.execute(mHttpGet);
      } catch (ClientProtocolException e) {
          // Handle exception
      } catch (IOException e) {
          // Handle exception
      } catch (Exception e) {
          // Handle exception
      }
  
      return ajaxResponse;
  
  }
  
  @Override
  protected void onProgressUpdate(HttpResponse... values) {
      // Do something with the response
  }
  </code></pre>
  
  <p>}</p>