Here you can find the source of sequence(List
public static <T> CompletableFuture<List<T>> sequence(List<CompletableFuture<T>> futures)
//package com.java2s; //License from project: Open Source License import java.util.List; import java.util.concurrent.*; import java.util.stream.Collectors; public class Main { public static <T> CompletableFuture<List<T>> sequence(List<CompletableFuture<T>> futures) { CompletableFuture<Void> allDoneFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])); return allDoneFuture.thenApply(v -> futures.stream().//www.j a va2 s . c o m map(future -> future.join()). collect(Collectors.<T>toList()) ); } }