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