FuturePool { public Future<Set<T>> all() { return allFinishedFuture.getFuture(); } FuturePool(); Future<T> listen(Future<T> future); Future<Set<T>> all(); Future<T> first();  }
@Test public void testAll() throws Exception { FuturePool<Integer> pool = new FuturePool<>(); long start = System.currentTimeMillis(); pool.listen(delayed(40, 3)); pool.listen(delayed(10, 2)); Set<Integer> result = pool.all().await(); long end = System.currentTimeMillis(); long duration = end - start; assertEquals(2, result.size()); assertTrue(result.contains(2)); assertTrue(result.contains(3)); assertTrue(duration >= 40); }