title: Throw a Composite Exception in Java
body: <p>I'm using <code>ExecutorService</code>, <code>Future</code> and <code>Callable</code> to do parallel processing. Though the <code>Callable</code>'s exception can be caught when invoking <code>Future#get</code>, how to catch all the exceptions thrown by all callables and then throw a huge, compound exception, like:</p>
  
  <pre><code>ExecutorService service = Executors.newFixedThreadPool(5);
  List&lt;Future&lt;Void&gt;&gt; futures = new ArrayList&lt;Future&lt;Void&gt;&gt;();
  futures.add(service.submit(new TaskA());
  futures.add(service.submit(new TaskB());
  
  for (Future&lt;Void&gt; future : futures) {
      try {
          future.get();
      } catch (Exception e) {
          // ???
      }
  }
  
  // throw the big exception here
  
  service.shutdown();
  </code></pre>