Created
October 16, 2021 18:51
-
-
Save samuelteixeiras/e92095a5a7df8ff586d574586bddb470 to your computer and use it in GitHub Desktop.
CompletedFuture with streams part 2
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
private static List<Integer> getIntegerList2(List<Integer> numbers) { | |
return numbers | |
.stream() | |
.map( | |
number -> | |
CompletableFuture.supplyAsync( | |
() -> getNumberCalculation(number), | |
executor | |
) | |
) | |
.collect(Collectors.toList()) | |
.stream() | |
.map(CompletableFuture::join) | |
.collect(Collectors.toList()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment