Skip to content

Instantly share code, notes, and snippets.

@rudrakshbhati
Last active February 20, 2021 18:41
Show Gist options
  • Save rudrakshbhati/b7544165660b2d40c207ae32cc824768 to your computer and use it in GitHub Desktop.
Save rudrakshbhati/b7544165660b2d40c207ae32cc824768 to your computer and use it in GitHub Desktop.
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