public class ForkJoinExecutorService extends AbstractExecutorService
ForkJoinExecutorService
is an ExecutorService
,
for efficient nested parallelization.
The ForkJoinPool
is an ExecutorService that provides
an entry point to a technique called work-steeling.
Work-steeling allows good performance for nested parallelization.
But calling ForkJoinPool.submit(java.util.concurrent.ForkJoinTask<T>)
or ForkJoinPool.invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>>)
alone, won't result in any work-steeling and performance boost.
It's necessary to use ForkJoinTask
s and their methods
fork
or invokeAll
to benefit from work-steeling.
ForkJoinExecutorService is an ExecutorService that internally calls ForkJoinTask.fork() and ForkJoinTask.invokeAll(...) and therefore directly achieves good performance by work-steeling.
ForkJoinExecutorService is not a fully functional ExecutorService.
Methods like shutdownNow()
, awaitTermination(long, TimeUnit)
and invokeAll(Collection, long, TimeUnit)
are not implemented.
Constructor and Description |
---|
ForkJoinExecutorService() |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long l,
TimeUnit timeUnit) |
void |
execute(Runnable runnable) |
int |
getParallelism() |
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> collection) |
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> collection,
long l,
TimeUnit timeUnit) |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
shutdown() |
List<Runnable> |
shutdownNow() |
<T> Future<T> |
submit(Callable<T> callable) |
Future<?> |
submit(Runnable runnable) |
<T> Future<T> |
submit(Runnable runnable,
T t) |
invokeAny, invokeAny, newTaskFor, newTaskFor
public int getParallelism()
public void shutdown()
public boolean isShutdown()
public boolean isTerminated()
public boolean awaitTermination(long l, TimeUnit timeUnit) throws InterruptedException
InterruptedException
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> collection) throws InterruptedException
invokeAll
in interface ExecutorService
invokeAll
in class AbstractExecutorService
InterruptedException
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> collection, long l, TimeUnit timeUnit) throws InterruptedException
invokeAll
in interface ExecutorService
invokeAll
in class AbstractExecutorService
InterruptedException
public Future<?> submit(Runnable runnable)
submit
in interface ExecutorService
submit
in class AbstractExecutorService
public <T> Future<T> submit(Runnable runnable, T t)
submit
in interface ExecutorService
submit
in class AbstractExecutorService
public <T> Future<T> submit(Callable<T> callable)
submit
in interface ExecutorService
submit
in class AbstractExecutorService
public void execute(Runnable runnable)
Copyright © 2015–2022 ImgLib2. All rights reserved.