Class ForkJoinExecutorService
- All Implemented Interfaces:
AutoCloseable, Executor, ExecutorService
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(ForkJoinTask) or ForkJoinPool.invokeAll(Collection, long)
alone, won't result in any work-steeling and performance boost.
It's necessary to use ForkJoinTasks 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long l, TimeUnit timeUnit) voidintprivate ForkJoinPoolgetPool()invokeAll(Collection<? extends Callable<T>> collection) invokeAll(Collection<? extends Callable<T>> collection, long l, TimeUnit timeUnit) booleanbooleanvoidshutdown()Future<?> <T> Future<T> <T> Future<T> Methods inherited from class AbstractExecutorService
invokeAny, invokeAny, newTaskFor, newTaskForMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ExecutorService
close
-
Constructor Details
-
ForkJoinExecutorService
public ForkJoinExecutorService()
-
-
Method Details
-
getParallelism
public int getParallelism() -
shutdown
public void shutdown() -
shutdownNow
-
isShutdown
public boolean isShutdown() -
isTerminated
public boolean isTerminated() -
awaitTermination
- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> collection) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Overrides:
invokeAllin classAbstractExecutorService- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> collection, long l, TimeUnit timeUnit) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Overrides:
invokeAllin classAbstractExecutorService- Throws:
InterruptedException
-
submit
- Specified by:
submitin interfaceExecutorService- Overrides:
submitin classAbstractExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService- Overrides:
submitin classAbstractExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService- Overrides:
submitin classAbstractExecutorService
-
execute
-
getPool
-