Last active
July 6, 2016 22:05
-
-
Save DeepSpawn/f3f33ffb4e51580666b0985a4d8a7781 to your computer and use it in GitHub Desktop.
This file contains 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
public static <T> CompletableFuture<List<T>> sequence(final List<CompletableFuture<T>> futures) { | |
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])) | |
.thenApply(unit -> futures | |
.stream() | |
.map(CompletableFuture::join) | |
.collect(toList())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment