Fork/Join framework Flashcards Preview

OCP > Fork/Join framework > Flashcards

Flashcards in Fork/Join framework Deck (19):
1

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

2

Executes a given task asynchronously.

void execute(ForkJoinTask> task)

3

Executes the given task and returns the computed result.

T invoke(ForkJoinTask task)

4

Executes all the given tasks and returns a list of future objects when all the tasks are completed.

List> invokeAll(Collection extends Callable> tasks)

5

Returns true if all tasks are completed.

boolean isTerminated()

6

Status checking methods.

getParallelism() getPoolSize() getStealCount()

7

Gets the number of threads the pool is using.

int getActiveThreadCount()

8

Executes a submitted task.

ForkJoinTask submit(Callable task)

9

A lightweight thread like entity representing a task. Defines methods fork() and join()

ForkJoinTask

10

Attempts to cancel the execution of the task.

boolean cancel(boolean mayInterruptIfRunning)

11

Executes the task asynchronously.

ForkJoinTask fork()

12

Returns the result of the computation when the computation is done.

V join()

13

Returns the result of the computation; waits if the computation is not complete.

V get()

14

Starts the execution of the submitted tasks; waits until computation is complete and returns results.

ForkJoinTask.invokeAll(collection tasks)

15

Returns true if the task is cancelled.

boolean isCancelled()

16

Returns true if the task is completed.

boolean isDone()

17

A task that can run in a ForkJoinPool. The compute method returns a value.

RecursiveTask

18

A task whose compute method does not return a value. This task can run in a fork join pool.

RecursiveAction

19

Method that performs the work of a ForkJoinTask if the unit is small enough. Must be overridden.

compute()