Created
November 18, 2020 12:27
-
-
Save alfredrichards/4931ecce6ab3f78666b92e764d3c20c9 to your computer and use it in GitHub Desktop.
Combining two CompletableFuture objects in Java
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
// callback is executed after the completion of | |
// completableFuture1, completableFuture2 | |
completableFuture1.thenCombine(completableFuture2, biFunction); | |
completableFuture1.thenAcceptBoth(completableFuture2, biConsumer); | |
completableFuture1.runAfterBoth(completableFuture2, runnable); | |
// callback is executed after the completion of | |
// either one of completableFuture1 or completableFuture2 | |
completableFuture1.applyToEither(completableFuture2, function); | |
completableFuture1.acceptEither(completableFuture2, consumer); | |
completableFuture1.runAfterEither(completableFuture2, runnable); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment