@Test public void testFlowWithFixedThreadPool() throws Exception { pool = Executors.newFixedThreadPool(POOL_SIZE); List<CompletableFuture<Integer>> futures = new ArrayList<>(); for (int i = 0; i < 20; i++) { futures.add( CompletableFutureFlow.flowWithId(i, pool)); } futures.forEach(CompletableFutureFlow::getFuture); }
static CompletableFuture<Integer> flowWithId(int id, ExecutorService pool) { return firstOperation(id, pool) .thenCompose(__ -> secondOperation(id, pool)) .thenCompose(__ -> thirdOperation(id, pool)); }
CompletableFutureFlow { static CompletableFuture<Integer> flowWithId(int id, ExecutorService pool) { return firstOperation(id, pool) .thenCompose(__ -> secondOperation(id, pool)) .thenCompose(__ -> thirdOperation(id, pool)); } }
CompletableFutureFlow { static CompletableFuture<Integer> flowWithId(int id, ExecutorService pool) { return firstOperation(id, pool) .thenCompose(__ -> secondOperation(id, pool)) .thenCompose(__ -> thirdOperation(id, pool)); }  }
CompletableFutureFlow { static CompletableFuture<Integer> flowWithId(int id, ExecutorService pool) { return firstOperation(id, pool) .thenCompose(__ -> secondOperation(id, pool)) .thenCompose(__ -> thirdOperation(id, pool)); }   }
CompletableFutureFlow { static CompletableFuture<Integer> flowWithId(int id, ExecutorService pool) { return firstOperation(id, pool) .thenCompose(__ -> secondOperation(id, pool)) .thenCompose(__ -> thirdOperation(id, pool)); }    }