Skip to content

Instantly share code, notes, and snippets.

@samuelteixeiras
Created October 16, 2021 18:51
Show Gist options
  • Save samuelteixeiras/e92095a5a7df8ff586d574586bddb470 to your computer and use it in GitHub Desktop.
Save samuelteixeiras/e92095a5a7df8ff586d574586bddb470 to your computer and use it in GitHub Desktop.
CompletedFuture with streams part 2
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