Completable Future
CompletableFuture<Integer> future = CompletableFuture.supplyAsync(() -> 5);
CompletableFuture<String> transformedFuture = future.thenApply(result -> result * 2)
.thenApply(result -> "Transformed: " + result);CompletableFuture<Integer> future = CompletableFuture.supplyAsync(() -> 5);
CompletableFuture<Void> actionFuture = future.thenAccept(result -> System.out.println("Result: " + result));CompletableFuture<Void> future = CompletableFuture.supplyAsync(() -> 5)
.thenRun(() -> System.out.println("Computation completed"));Last updated