public final class ExecUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T,R> R |
collectInParallel(int numTasks,
int parallelism,
boolean privatePool,
Function<Integer,T> task,
Collector<T,?,R> collector) |
static void |
doInParallel(int numTasks,
Consumer<Integer> task) |
static void |
doInParallel(int numTasks,
int parallelism,
boolean privatePool,
Consumer<Integer> task) |
public static void doInParallel(int numTasks, Consumer<Integer> task)
numTasks
- how many copies of task
to run; all may be run simultaneously,
and a shared thread pool is usedtask
- task to execute; takes an Integer
argument that is the index of
the task that has been executed in [0, numTasks)public static void doInParallel(int numTasks, int parallelism, boolean privatePool, Consumer<Integer> task)
numTasks
- how many copies of task
to runparallelism
- maximum how many tasks to run simultaneouslyprivatePool
- whether to create and use a new private thread pool; otherwise
a shared pool is used. No parallelism or pool is used if parallelism
is 1task
- task to execute; takes an Integer
argument that is the index of
the task that has been executed in [0, numTasks)public static <T,R> R collectInParallel(int numTasks, int parallelism, boolean privatePool, Function<Integer,T> task, Collector<T,?,R> collector)
T
- type produced by each taskR
- type produced by collector
from task resultsnumTasks
- how many copies of task
to runparallelism
- maximum how many tasks to run simultaneouslyprivatePool
- whether to create and use a new private thread pool; otherwise
a shared pool is used. No parallelism or pool is used if parallelism
is 1task
- task to execute; takes an Integer
argument that is the index of
the task that has been executed in [0, numTasks) and returns some valuecollector
- instance used to collect results into the return valueCopyright © 2014–2018. All rights reserved.