### Question:
Futures { public static <T> CompletableFuture<T> afterTimeout(T value, long millis) { CompletableFuture<T> future = new CompletableFuture<>(); timer.newTimeout(t -> future.complete(value), millis, TimeUnit.MILLISECONDS); return future; }  static CompletableFuture<T> afterTimeout(T value, long millis);  }### Answer:
@Test public void afterTimeout() throws InterruptedException { CountDownLatch latch = new CountDownLatch(1); Set<String> resultHolder = Collections.newSetFromMap(new ConcurrentHashMap<>()); CompletableFuture<String> slow = Futures.afterTimeout("slow", 1000); CompletableFuture<String> fast = Futures.afterTimeout("fast", 1); fast.acceptEither(slow, result -> { resultHolder.add(result); latch.countDown(); }); latch.await(); Assert.assertEquals("fast", resultHolder.iterator().next()); }