source: class FuturityTest {
  
      @Test
      public void finalizingALotOfFutures() {
  
target:         ExecutorService executorService = Executors.newFixedThreadPool(50);
          try {
              List<CompletableFuture<?>> futures = new ArrayList<>(1000);
  
              for (int i = 0; i < 1000; i++) {
                  futures.add(Futurity.shift(executorService.submit(new Callable<Object>() {
                      private final Random rnd = new Random();
  
                      @Override
                      public Object call() throws Exception {
                          Thread.sleep(rnd.nextInt(5));
                          return new Object();
                      }
                  })));
              }
  
              CountDownLatch countDownLatch = new CountDownLatch(500);
              futures.forEach(future -> future.thenAccept(i -> countDownLatch.countDown()));
              await("Some futures are not finalized")
                      .atMost(5, TimeUnit.SECONDS).until(() -> countDownLatch.getCount() == 0);
          } finally {
              executorService.shutdown();
          }
      }
  
  }