Last active
February 20, 2021 18:41
-
-
Save rudrakshbhati/b7544165660b2d40c207ae32cc824768 to your computer and use it in GitHub Desktop.
This file contains 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
private static void chainingExample(){ | |
CompletableFuture<String> completableFuture | |
= CompletableFuture.supplyAsync(() -> "Hello ") | |
.thenCompose(s -> CompletableFuture.supplyAsync(() -> s + "My ")) | |
.thenCompose(s -> CompletableFuture.supplyAsync(() -> s + "Friend")); | |
try { | |
System.out.print(completableFuture.get()); | |
} catch (Exception e) { | |
System.out.print("exception occurred"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment