title: CountDownLatch.await() suspending background threads
body: <p>I'm working on an android app which at some point runs a service. That service runs a new thread for a time-consuming operation and waits for a countDownLatch to be zero. After that it runs a second thread for another time-consuming operation (that new thread isn't really necessary now but will be in the near future).</p>
  
  <p>Now...after starting the downloadThread, if I do the waiting as shown below, the main thread AND the downloadThread suspend operations. However, if I wait for the countDownLatch inside the uploadThread everything works fine.</p>
  
  <pre><code>Thread downloadThread = new Thread(new Runnable() {
   @Override
   public void run() {
     downloadFiles(mMediaFileList);
   }
  });
  
  downloadThread.start();
  
  try {
   Log.d("UploadMedia", "Waiting for DownloadMedia to finish");
   mCountDownLatch.await();
  } catch (InterruptedException e) {
   e.printStackTrace();
  }
  
  Thread uploadThread = new Thread(new Runnable() {
   @Override
   public void run() {
    uploadMedia();
   }
  });
  
  uploadThread.start();
  </code></pre>
  
  <p>It's not really a problem but isn't it supposed to work both ways? Is there something I'm missing about the .await() functionality?</p>
  
  <p>Cheers!</p>
  
  <p><strong>Edit:</strong> FYI, downloadFiles has callbacks which wait for completion or failure of the task. Can it be that those callbacks work on the main thread which is being suspended by the .await()?</p>