Java Thread Future sequence(List> futures)

Here you can find the source of sequence(List> futures)

Description

sequence

License

Open Source License

Declaration

public static <T> CompletableFuture<List<T>> sequence(List<CompletableFuture<T>> futures) 

Method Source Code

    //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())
    );
}
    }

Related

  1. nanoTime()
  2. now(Collection> s)
  3. rollback(Object tx)
  4. runIfNotDoneAndGet(RunnableFuture future)
  5. runInNewThread(String threadName, Runnable target)
  6. sequence(List> futures)
  7. sequence(List> futures)
  8. sequence(List> futures)
  9. submitTasks(ExecutorCompletionService ecs, Iterable> tasks)