Fork/Join framework Flashcards

1
Q

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.

A

ForkJoinPool

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Executes a given task asynchronously.

A

void execute(ForkJoinTask> task)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Executes the given task and returns the computed result.

A

T invoke(ForkJoinTask task)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

List> invokeAll(Collection extends Callable> tasks)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Returns true if all tasks are completed.

A

boolean isTerminated()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Status checking methods.

A

getParallelism() getPoolSize() getStealCount()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Gets the number of threads the pool is using.

A

int getActiveThreadCount()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Executes a submitted task.

A

ForkJoinTask submit(Callable task)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

A

ForkJoinTask

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Attempts to cancel the execution of the task.

A

boolean cancel(boolean mayInterruptIfRunning)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Executes the task asynchronously.

A

ForkJoinTask fork()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A

V join()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

A

V get()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

ForkJoinTask.invokeAll(collection tasks)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Returns true if the task is cancelled.

A

boolean isCancelled()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Returns true if the task is completed.

A

boolean isDone()

17
Q

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

A

RecursiveTask

18
Q

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

A

RecursiveAction

19
Q

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

A

compute()