public class Parallel extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Parallel.Method<T> |
| Constructor and Description |
|---|
Parallel() |
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
forLoop(int nThreads,
List<T> list,
Parallel.Method<T> function,
long timeout,
TimeUnit unit)
Run
function on each item of list in parallel, using nThreads
threads. |
static <T,S> List<S> |
map(int nThreads,
List<T> list,
ITransformer<T,S> function,
long timeout,
TimeUnit unit)
Run
function on each item of list in parallel, using nThreads
threads. |
public static <T,S> List<S> map(int nThreads, List<T> list, ITransformer<T,S> function, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException
function on each item of list in parallel, using nThreads
threads. The output is a list that has the same size as list, where each element has
been transformed according to the input function.nThreads - Number of threads to uselist - The input listfunction - A function to apply to each element of the listtimeout - Timeoutunit - Units for the timeoutInterruptedExceptionExecutionExceptionpublic static <T> void forLoop(int nThreads,
List<T> list,
Parallel.Method<T> function,
long timeout,
TimeUnit unit)
throws InterruptedException
function on each item of list in parallel, using nThreads
threads.nThreads - Number of threads to uselist - The input listfunction - A function to apply to each element of the listtimeout - Timeoutunit - Units for the timeoutInterruptedExceptionCopyright © 2017. All rights reserved.