Example usage for org.apache.hadoop.util.concurrent HadoopExecutors newFixedThreadPool

List of usage examples for org.apache.hadoop.util.concurrent HadoopExecutors newFixedThreadPool

Introduction

In this page you can find the example usage for org.apache.hadoop.util.concurrent HadoopExecutors newFixedThreadPool.

Prototype

public static ExecutorService newFixedThreadPool(int nThreads) 

Source Link

Usage

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*/
}