List of usage examples for org.apache.hadoop.util.concurrent HadoopExecutors newFixedThreadPool
public static ExecutorService newFixedThreadPool(int nThreads)
From source file:org.apache.hadoop.examples.pi.Util.java
License:Apache License
/** Execute the callables by a number of threads */ public static <T, E extends Callable<T>> void execute(int nThreads, List<E> callables) throws InterruptedException, ExecutionException { final ExecutorService executor = HadoopExecutors.newFixedThreadPool(nThreads); final List<Future<T>> futures = executor.invokeAll(callables); for (Future<T> f : futures) f.get();/*from w w w .java 2s . co m*/ }