Fork/Join framework Flashcards
The most important class in the Fork/Join framework. It is a thread pool for running fork/join tasks. It executes an instance of ForkJoinTask.
ForkJoinPool
Executes a given task asynchronously.
void execute(ForkJoinTask> task)
Executes the given task and returns the computed result.
T invoke(ForkJoinTask task)
Executes all the given tasks and returns a list of future objects when all the tasks are completed.
List> invokeAll(Collection extends Callable> tasks)
Returns true if all tasks are completed.
boolean isTerminated()
Status checking methods.
getParallelism() getPoolSize() getStealCount()
Gets the number of threads the pool is using.
int getActiveThreadCount()
Executes a submitted task.
ForkJoinTask submit(Callable task)
A lightweight thread like entity representing a task. Defines methods fork() and join()
ForkJoinTask
Attempts to cancel the execution of the task.
boolean cancel(boolean mayInterruptIfRunning)
Executes the task asynchronously.
ForkJoinTask fork()
Returns the result of the computation when the computation is done.
V join()
Returns the result of the computation; waits if the computation is not complete.
V get()
Starts the execution of the submitted tasks; waits until computation is complete and returns results.
ForkJoinTask.invokeAll(collection tasks)
Returns true if the task is cancelled.
boolean isCancelled()