Skip to content

Instantly share code, notes, and snippets.

@samuelteixeiras
Last active October 16, 2021 19:38
Show Gist options
  • Save samuelteixeiras/2f5aaa62eef2ec7c62fa04e9eaba4d5b to your computer and use it in GitHub Desktop.
Save samuelteixeiras/2f5aaa62eef2ec7c62fa04e9eaba4d5b to your computer and use it in GitHub Desktop.
CompletedFuture with streams part 1
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