BAEL-5814 - Is CompletableFuture Non-blocking (#13917)

* BAEL-5814 - Is CompletableFuture Non-blocking

* Fix the formatting
This commit is contained in:
Ana Peterlić
2023-05-04 03:55:07 +02:00
committed by GitHub
parent bd11f1859f
commit f59ab8a4ae
2 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
package com.baeldung.concurrent.completablefuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.CompletableFuture;
public class NonBlockingExample {
private static final Logger logger = LoggerFactory.getLogger(NonBlockingExample.class);
public static void main(String[] args) {
CompletableFuture.supplyAsync(() -> "Baeldung")
.thenApply(String::length)
.thenAccept(s -> logger.info(String.valueOf(s)));
}
}