Here you can find the source of submitManyAndWait(ListeningExecutorService service, Iterable
public static <T> List<T> submitManyAndWait(ListeningExecutorService service, Iterable<Callable<T>> cas, FutureCallback<T> fca) throws InterruptedException, ExecutionException
//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(); } }