Created
August 15, 2019 02:48
-
-
Save fromdev/0a7c869ca1b05701580e0041f5ada14e to your computer and use it in GitHub Desktop.
SampleAsyncCallInSequence - Supplier Lambda Example Code
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
MyClass myobject = new MyClass(); | |
CompletableFuture<Data> dataCompletableFuture1 = CompletableFuture.supplyAsync(() -> myobject.getData1()); // first Async call | |
CompletableFuture<Data> dataCompletableFuture2 = CompletableFuture.supplyAsync(() -> myobject.getData2()); // second Async call | |
CompletableFuture<Data> dataCompletableFuture3 = CompletableFuture.supplyAsync(() -> myobject.getData3()); // third Async call | |
//Now the code to combine in sequence | |
dataCompletableFuture1 | |
.thenCombine(dataCompletableFuture2, Aggregator::combine) | |
.thenCombine(dataCompletableFuture3, Aggregator::combine); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment