public final class TaskExecutors extends Object
TaskExecutor
s.Modifier and Type | Method and Description |
---|---|
static ThreadFactory |
applyTaskExecutorToThreadFactory(Supplier<TaskExecutor> taskExecutorFactory,
ThreadFactory threadFactory)
Returns a
ThreadFactory . |
static TaskExecutor |
fixedThreadPool(int numThreads)
Returns a
TaskExecutor that uses a fixed thread pool with the
given number of threads. |
static TaskExecutor |
forExecutorService(ExecutorService executorService)
Creates a
TaskExecutor that wraps around given ExecutorService . |
static TaskExecutor |
forExecutorServiceAndNumTasks(ExecutorService executorService,
int numTasks)
Creates a
TaskExecutor that wraps around given ExecutorService ,
and will suggest the given number of tasks when asked. |
static TaskExecutor |
forExecutorServiceAndNumThreads(ExecutorService executorService,
int numThreads)
Creates a
TaskExecutor that wraps around given ExecutorService ,
and will return the given parallelism. |
static TaskExecutor |
multiThreaded()
TaskExecutor for multi-threaded execution. |
static TaskExecutor |
nestedFixedThreadPool(int numThreads,
int numSubThreads)
Returns a
TaskExecutor that uses a fixed thread pool with the
given number of threads. |
static TaskExecutor |
numThreads(int numThreads)
TaskExecutor that uses the given number or threads. |
static TaskExecutor |
singleThreaded()
TaskExecutor for single threaded execution. |
static ThreadFactory |
threadFactory(Supplier<TaskExecutor> taskExecutorFactory)
Returns a
ThreadFactory . |
public static TaskExecutor singleThreaded()
TaskExecutor
for single threaded execution.public static TaskExecutor multiThreaded()
TaskExecutor
for multi-threaded execution.
ForkJoinPool
is used.public static TaskExecutor numThreads(int numThreads)
TaskExecutor
that uses the given number or threads.
The TaskExecutor
needs to be closed by calling TaskExecutor.close()
.public static TaskExecutor forExecutorService(ExecutorService executorService)
TaskExecutor
that wraps around given ExecutorService
.public static TaskExecutor forExecutorServiceAndNumThreads(ExecutorService executorService, int numThreads)
TaskExecutor
that wraps around given ExecutorService
,
and will return the given parallelism.public static TaskExecutor forExecutorServiceAndNumTasks(ExecutorService executorService, int numTasks)
TaskExecutor
that wraps around given ExecutorService
,
and will suggest the given number of tasks when asked.public static TaskExecutor fixedThreadPool(int numThreads)
TaskExecutor
that uses a fixed thread pool with the
given number of threads.public static TaskExecutor nestedFixedThreadPool(int numThreads, int numSubThreads)
TaskExecutor
that uses a fixed thread pool with the
given number of threads. But that's not the end of the story.
Each of the threads uses itself a fixed thread pool with the given number of sub threads.
This TaskExecutor
is useful for nested parallelization,
when detailed control for the level of parallelism is needed.
public static ThreadFactory threadFactory(Supplier<TaskExecutor> taskExecutorFactory)
ThreadFactory
. Whenever this thread factory is used
to create a thread, a TaskExecutor
will is create and assigned
to the thread. The TaskExecutor
is created using the given supplier.public static ThreadFactory applyTaskExecutorToThreadFactory(Supplier<TaskExecutor> taskExecutorFactory, ThreadFactory threadFactory)
ThreadFactory
. Whenever this thread factory is used
to create a thread, a TaskExecutor
will is create and assigned
to the thread. The threads created, are using the given thread factory,
and the TaskExecutors
are create using the given supplier.Copyright © 2015–2022 ImgLib2. All rights reserved.