Created
July 16, 2021 10:53
-
-
Save wkdalsgh192/99c7eeb7e3ddfb6bfd3cb5453efdfbb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using a callback method | |
CompletableFuture<String> future4 = CompletableFuture.supplyAsync(() -> { | |
System.out.println("Hello "+ Thread.currentThread().getName()); | |
return "Hello"; | |
}).thenApply((s) -> { // thenApply, thenAccept or thenRun can also be used here | |
System.out.println(Thread.currentThread().getName()); | |
return s.toUpperCase(Locale.ROOT); | |
}); | |
System.out.println(future4.get()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment