Java tutorial
//package com.java2s; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; public class Main { public static void waitOnFutures(Iterable<Future<?>> futures) { for (Future f : futures) waitOnFuture(f); } public static <T> T waitOnFuture(Future<T> future) { try { return future.get(); } catch (ExecutionException ee) { throw new RuntimeException(ee); } catch (InterruptedException ie) { throw new AssertionError(ie); } } }