title: Creating a looping background task
body: <p>I'd like to create an AsyncTask that sits in the background and calls a web service every X seconds.</p>
  
  <pre><code>    private class BackgroundTask extends AsyncTask&lt;Integer, Integer, Boolean&gt; {
      protected Boolean doInBackground(Integer... params) {
          if (params.length &gt; 0) {
              int intUserId = params[0];
  
              if (intUserId != -1) {
                  boolean blnRunning = true;
                  while (blnRunning) {
                      // perform query
  
                      try {
                          this.wait(15000);
                      }
                      catch (InterruptedException e) {
                          blnRunning = false;
                      }
                  }
              }
          }
  
          return false;
      }
  
      protected void onPostExecute(Boolean blnLaunchStoreFavorites) {
          // do something?
      }
  }
  </code></pre>
  
  <p>This is what I have.</p>
  
  <p>Shortly after this.wait() is called, I get an error down in the bowels of ThreadPoolExecuter.class.</p>
  
  <pre><code>Uncaught handler: thread AsyncTask #2 exiting due to uncaught exception
  java.lang.RuntimeException: An error occured while executing doInBackground()
  at android.os.AsyncTask$3.done(AsyncTask.java:200)
  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  at java.lang.Thread.run(Thread.java:1096)
  </code></pre>
  
  <p>I'm not quite sure what is going on here.  Any ideas?</p>