title: How to wait for all callables to finish executing before proceeding?
body: <p>I have the following code hashed out:</p>
  
  <pre><code>public class MyCallable implements Callable&lt;Long&gt; {
      @Override
      public Long call() throws Exception {
          // Do stuff...
      }
  }
  
  public class MyController {
      private ExecutorService executor = Executos.newCachedTreadPool();
  
      public Long concurrentDoStuff() {
          List&lt;MyCallable&gt; workers = makeWorkers();
  
          List&lt;Long&gt; allResults = new ArrayList&lt;Long&gt;();
          for(MyCallable worker : workers) {
              Future&lt;Long&gt; workerResults = executor.submit(worker);
  
              try {
                  allResults.add(workerResults.get());
              } catch(InterruptedException ie) {
                  // Handle...
              } catch(ExecutionException ee) {
                  // Handle...
              }
          }
  
          // Question: how do I pause here and wait for all workers to finish?
      }
  }
  </code></pre>
  
  <p>After the <code>for</code>-loop, I want to wait for all workers to finish before proceeding any further. What's the best/safest/most-efficient way to do this? Thanks in advance!</p>