title: How to wait for all tasks in an ThreadPoolExecutor to finish without shutting down the Executor?
body: <p>I can't use <code>shutdown()</code> and <code>awaitTermination()</code> because it is possible new tasks will be added to the ThreadPoolExecutor while it is waiting.</p>
  
  <p>So I'm looking for a way to wait until the ThreadPoolExecutor has emptied it's queue and finished all of it's tasks without stopping new tasks from being added before that point.</p>
  
  <p>If it makes any difference, this is for Android.</p>
  
  <p>Thanks</p>
  
  <p><strong>Update</strong>: Many weeks later after revisiting this, I discovered that a modified CountDownLatch worked better for me in this case.  I'll keep the answer marked because it applies more to what I asked.</p>