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