title: Asynchronous call within Callable
body: <p>Consider the following Java code (a simplified version of what I am working with - if there are errors it's because I haven't run it through a compiler):</p>
  
  <pre><code>CountdownLatch latch = new CountdownLatch(collection.size());
  
  for(Whatever thing : collection){
  
      provider.doWork(thing, result -&gt; {
          process(result);
          latch.countDown();
      };
  }
  
  try {
      latch.await();
  } catch (InterruptedException ignore) {}
  
  doMoreWork();
  </code></pre>
  
  <p>So I run a number of asynchronous tasks, and wait for them all to be done before proceeding.  Right now I'm accumulating the result of the asynchronous tasks in a list.  This works and it's fine, but I'm looking at whether there's a cleaner implementation using Futures or something similar.  The issue is the asynchronous call.  A Callable is supposed to return the result of its work, but the result of this work won't be known until later.  It's not worth rewriting <code>doWork</code> to be synchronous.  Should I just leave this alone, or is there an option out there?  Partly my interest is in better code but partly in just learning more about concurrency options.  If it matters, this is in an Android app.</p>