BAEL-5814 - Is CompletableFuture Non-blocking (#13917)
* BAEL-5814 - Is CompletableFuture Non-blocking * Fix the formatting
This commit is contained in:
@@ -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)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user