Java Thread Future getAll(List> futures)

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

Description

get All

License

Open Source License

Declaration

public static <T> List<T> getAll(List<Future<T>> futures) 

Method Source Code

//package com.java2s;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;

public class Main {
    public static <T> List<T> getAll(List<Future<T>> futures) {
        try {//from   w  w  w .  j a  v  a2 s .  c  o  m
            List<T> result = new ArrayList<T>(futures.size());
            for (Future<T> future : futures) {
                result.add(future.get());
            }
            return result;
        } catch (Exception e) {
            throw new RuntimeException(
                    "Exception while getting result of multiple futures", e);
        }
    }
}

Related

  1. convertFuture(Future future)
  2. createFuture()
  3. exceptionallyCompletedFuture( final Throwable e)
  4. exceptionallyCompletedFuture(final Throwable t)
  5. getAll(List> futures)
  6. getAllDone(Collection futures)
  7. getExceptionFromNewThread(String threadName, Runnable target)
  8. getFailedFuture(Throwable throwable)
  9. getFuture(Future future, String message)