Java Thread Callable submitManyAndWait(ListeningExecutorService service, Iterable> cas, FutureCallback fca)

Here you can find the source of submitManyAndWait(ListeningExecutorService service, Iterable> cas, FutureCallback fca)

Description

submit Many And Wait

License

Apache License

Declaration

public static <T> List<T> submitManyAndWait(ListeningExecutorService service, Iterable<Callable<T>> cas,
            FutureCallback<T> fca) throws InterruptedException, ExecutionException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;

public class Main {
    public static <T> List<T> submitManyAndWait(ListeningExecutorService service, Iterable<Callable<T>> cas,
            FutureCallback<T> fca) throws InterruptedException, ExecutionException {
        List<ListenableFuture<T>> lfs = new ArrayList<>();

        for (Callable<T> ca : cas) {
            lfs.add(service.submit(ca));
        }/*from w ww.ja  v a2  s.c  om*/
        return Futures.successfulAsList(lfs).get();
    }
}

Related

  1. runInBackground(final Callable callable)
  2. runTest(Callable test)
  3. runWithTimeout(long millisTimeout, Callable callable)
  4. shuffleRow(final double[] data)
  5. submitAndWait(ListeningExecutorService service, Callable ca)
  6. sum(final double[] a)
  7. sumOfSquares(final double[] data)
  8. waitFor(final Process process, final CyclicBarrier onStart)
  9. waitFor(Object o, long ms, Callable c)