# ForkJoinPool

public class **ForkJoinPool** extends [AbstractExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/AbstractExecutorService.html)  
An `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html` for running `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html`s.
A `ForkJoinPool` provides the entry point for submissions
from non-`ForkJoinTask` clients, as well as management and
monitoring operations.

A `ForkJoinPool` differs from other kinds of `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html` mainly by virtue of employing
*work-stealing* : all threads in the pool attempt to find and
execute tasks submitted to the pool and/or created by other active
tasks (eventually blocking waiting for work if none exist). This
enables efficient processing when most tasks spawn other subtasks
(as do most `ForkJoinTask`s), as well as when many small
tasks are submitted to the pool from external clients. Especially
when setting *asyncMode* to true in constructors, `ForkJoinPool`s may also be appropriate for use with event-style
tasks that are never joined.

A static `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#commonPool()` is available and appropriate for
most applications. The common pool is used by any ForkJoinTask that
is not explicitly submitted to a specified pool. Using the common
pool normally reduces resource usage (its threads are slowly
reclaimed during periods of non-use, and reinstated upon subsequent
use).

For applications that require separate or custom pools, a `ForkJoinPool` may be constructed with a given target parallelism
level; by default, equal to the number of available processors.
The pool attempts to maintain enough active (or available) threads
by dynamically adding, suspending, or resuming internal worker
threads, even if some tasks are stalled waiting to join others.
However, no such adjustments are guaranteed in the face of blocked
I/O or other unmanaged synchronization. The nested `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.ManagedBlocker.html` interface enables extension of the kinds of
synchronization accommodated.

In addition to execution and lifecycle control methods, this
class provides status check methods (for example
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#getStealCount()`) that are intended to aid in developing,
tuning, and monitoring fork/join applications. Also, method
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#toString()` returns indications of pool state in a
convenient form for informal monitoring.

As is the case with other ExecutorServices, there are three
main task execution methods summarized in the following table.
These are designed to be used primarily by clients not already
engaged in fork/join computations in the current pool. The main
forms of these methods accept instances of `ForkJoinTask`,
but overloaded forms also allow mixed execution of plain `Runnable`- or `Callable`- based activities as well. However,
tasks that are already executing in a pool should normally instead
use the within-computation forms listed in the table unless using
async event-style tasks that are not usually joined, in which case
there is little difference among choice of methods.

|---|---|---|
|   | **Call from non-fork/join clients** | **Call from within fork/join computations** |
| **Arrange async execution** | `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#execute(java.util.concurrent.ForkJoinTask<?>)` | `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html#fork()` |
| **Await and obtain result** | `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#invoke(java.util.concurrent.ForkJoinTask<T>)` | `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html#invoke()` |
| **Arrange exec and obtain Future** | `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#submit(java.util.concurrent.ForkJoinTask<T>)` | `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html#fork()` (ForkJoinTasks *are* Futures) |
[Summary of task execution methods]

The common pool is by default constructed with default
parameters, but these may be controlled by setting three
{@linkplain System#getProperty system properties}:

- `java.util.concurrent.ForkJoinPool.common.parallelism` - the parallelism level, a non-negative integer
- `java.util.concurrent.ForkJoinPool.common.threadFactory` - the class name of a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory.html`
- `java.util.concurrent.ForkJoinPool.common.exceptionHandler` - the class name of a `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Thread.UncaughtExceptionHandler.html`
- `java.util.concurrent.ForkJoinPool.common.maximumSpares` - the maximum number of allowed extra threads to maintain target parallelism (default 256).

If a `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html` is present and no factory is specified, then the default pool uses a factory supplying threads that have no `https://developers.google.com/j2objc/javadoc/jre/` enabled. The system class loader is used to load these classes. Upon any error in establishing these settings, default parameters are used. It is possible to disable or limit the use of threads in the common pool by setting the parallelism property to zero, and/or using a factory that may return `null`. However doing so may cause unjoined tasks to never be executed.

**Implementation notes** : This implementation restricts the
maximum number of running threads to 32767. Attempts to create
pools with greater than the maximum number result in
`IllegalArgumentException`.

This implementation rejects submitted tasks (that is, by throwing
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RejectedExecutionException.html`) only when the pool is shut down
or internal resources have been exhausted.

### Nested Class Summary

|---|---|---|---|
| interface | [ForkJoinPool.ForkJoinWorkerThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory.html) || Factory for creating new `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinWorkerThread.html`s. |
| interface | [ForkJoinPool.ManagedBlocker](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.ManagedBlocker.html) || Interface for extending managed parallelism for tasks running in `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html`s. |

### Field Summary

|---|---|---|
| public static final [ForkJoinPool.ForkJoinWorkerThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory.html) | [defaultForkJoinWorkerThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#defaultForkJoinWorkerThreadFactory) | Creates a new ForkJoinWorkerThread. |

### Public Constructor Summary

|---|---|
|   | [ForkJoinPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#ForkJoinPool())() Creates a `ForkJoinPool` with parallelism equal to `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runtime.html#availableProcessors()`, using the {@linkplain #defaultForkJoinWorkerThreadFactory default thread factory}, no UncaughtExceptionHandler, and non-async LIFO processing mode. |
|   | [ForkJoinPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#ForkJoinPool(int))(int parallelism) Creates a `ForkJoinPool` with the indicated parallelism level, the {@linkplain #defaultForkJoinWorkerThreadFactory default thread factory}, no UncaughtExceptionHandler, and non-async LIFO processing mode. |
|   | [ForkJoinPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#ForkJoinPool(int,%20java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory,%20java.lang.Thread.UncaughtExceptionHandler,%20boolean))(int parallelism, [ForkJoinPool.ForkJoinWorkerThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory.html) factory, Thread.UncaughtExceptionHandler handler, boolean asyncMode) Creates a `ForkJoinPool` with the given parameters. |

### Public Method Summary

|---|---|
| boolean | [awaitQuiescence](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#awaitQuiescence(long,%20java.util.concurrent.TimeUnit))(long timeout, [TimeUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/TimeUnit.html) unit) If called by a ForkJoinTask operating in this pool, equivalent in effect to `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html#helpQuiesce()`. |
| boolean | [awaitTermination](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#awaitTermination(long,%20java.util.concurrent.TimeUnit))(long timeout, [TimeUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/TimeUnit.html) unit) Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first. |
| static [ForkJoinPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html) | [commonPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#commonPool())() Returns the common pool instance. |
| void | [execute](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#execute(java.lang.Runnable))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) task) |
| void | [execute](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#execute(java.util.concurrent.ForkJoinTask<?>))([ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<?\> task) Arranges for (asynchronous) execution of the given task. |
| int | [getActiveThreadCount](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#getActiveThreadCount())() Returns an estimate of the number of threads that are currently stealing or executing tasks. |
| boolean | [getAsyncMode](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#getAsyncMode())() Returns `true` if this pool uses local first-in-first-out scheduling mode for forked tasks that are never joined. |
| static int | [getCommonPoolParallelism](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#getCommonPoolParallelism())() Returns the targeted parallelism level of the common pool. |
| [ForkJoinPool.ForkJoinWorkerThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory.html) | [getFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#getFactory())() Returns the factory used for constructing new workers. |
| int | [getParallelism](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#getParallelism())() Returns the targeted parallelism level of this pool. |
| int | [getPoolSize](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#getPoolSize())() Returns the number of worker threads that have started but not yet terminated. |
| int | [getQueuedSubmissionCount](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#getQueuedSubmissionCount())() Returns an estimate of the number of tasks submitted to this pool that have not yet begun executing. |
| long | [getQueuedTaskCount](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#getQueuedTaskCount())() Returns an estimate of the total number of tasks currently held in queues by worker threads (but not including tasks submitted to the pool that have not begun executing). |
| int | [getRunningThreadCount](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#getRunningThreadCount())() Returns an estimate of the number of worker threads that are not blocked waiting to join tasks or for other managed synchronization. |
| long | [getStealCount](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#getStealCount())() Returns an estimate of the total number of tasks stolen from one thread's work queue by another. |
| Thread.UncaughtExceptionHandler | [getUncaughtExceptionHandler](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#getUncaughtExceptionHandler())() Returns the handler for internal worker threads that terminate due to unrecoverable errors encountered while executing tasks. |
| boolean | [hasQueuedSubmissions](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#hasQueuedSubmissions())() Returns `true` if there are any tasks submitted to this pool that have not yet begun executing. |
| \<T\> T | [invoke](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#invoke(java.util.concurrent.ForkJoinTask<T>))([ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<T\> task) Performs the given task, returning its result upon completion. |
| \<T\> [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[Future](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html)\<T\>\> | [invokeAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#invokeAll(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\>\> tasks) Executes the given tasks, returning a list of Futures holding their status and results when all complete. |
| boolean | [isQuiescent](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#isQuiescent())() Returns `true` if all worker threads are currently idle. |
| boolean | [isShutdown](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#isShutdown())() Returns `true` if this pool has been shut down. |
| boolean | [isTerminated](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#isTerminated())() Returns `true` if all tasks have completed following shut down. |
| boolean | [isTerminating](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#isTerminating())() Returns `true` if the process of termination has commenced but not yet completed. |
| static void | [managedBlock](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#managedBlock(java.util.concurrent.ForkJoinPool.ManagedBlocker))([ForkJoinPool.ManagedBlocker](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.ManagedBlocker.html) blocker) Runs the given possibly blocking task. |
| void | [shutdown](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#shutdown())() Possibly initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. |
| [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html)\> | [shutdownNow](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#shutdownNow())() Possibly attempts to cancel and/or stop all tasks, and reject all subsequently submitted tasks. |
| \<T\> [ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<T\> | [submit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#submit(java.util.concurrent.Callable<T>))([Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\> task) Submits a value-returning task for execution and returns a Future representing the pending results of the task. |
| \<T\> [ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<T\> | [submit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#submit(java.util.concurrent.ForkJoinTask<T>))([ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<T\> task) Submits a ForkJoinTask for execution. |
| [ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<?\> | [submit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#submit(java.lang.Runnable))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) task) Submits a Runnable task for execution and returns a Future representing that task. |
| \<T\> [ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<T\> | [submit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#submit(java.lang.Runnable,%20T))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) task, T result) Submits a Runnable task for execution and returns a Future representing that task. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#toString())() Returns a string identifying this pool, as well as its state, including indications of run state, parallelism level, and worker and task counts. |

### Protected Method Summary

|---|---|
| int | [drainTasksTo](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#drainTasksTo(java.util.Collection<?%20super%20java.util.concurrent.ForkJoinTask<?>>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? super [ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<?\>\> c) Removes all available unexecuted submitted and forked tasks from scheduling queues and adds them to the given collection, without altering their execution status. |
| \<T\> [RunnableFuture](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RunnableFuture.html)\<T\> | [newTaskFor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#newTaskFor(java.lang.Runnable,%20T))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) runnable, T value) Returns a `RunnableFuture` for the given runnable and default value. |
| \<T\> [RunnableFuture](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RunnableFuture.html)\<T\> | [newTaskFor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#newTaskFor(java.util.concurrent.Callable<T>))([Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\> callable) Returns a `RunnableFuture` for the given callable task. |
| [ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<?\> | [pollSubmission](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#pollSubmission())() Removes and returns the next unexecuted submission if one is available. |

### Inherited Method Summary

From class [java.util.concurrent.AbstractExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/AbstractExecutorService.html)

|---|---|
| \<T\> [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[Future](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html)\<T\>\> | [invokeAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/AbstractExecutorService.html#invokeAll(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\>\> tasks) Executes the given tasks, returning a list of Futures holding their status and results when all complete. |
| \<T\> [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[Future](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html)\<T\>\> | [invokeAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/AbstractExecutorService.html#invokeAll(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>,%20long,%20java.util.concurrent.TimeUnit))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\>\> tasks, long timeout, [TimeUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/TimeUnit.html) unit) Executes the given tasks, returning a list of Futures holding their status and results when all complete or the timeout expires, whichever happens first. |
| \<T\> T | [invokeAny](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/AbstractExecutorService.html#invokeAny(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\>\> tasks) Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do. |
| \<T\> T | [invokeAny](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/AbstractExecutorService.html#invokeAny(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>,%20long,%20java.util.concurrent.TimeUnit))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\>\> tasks, long timeout, [TimeUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/TimeUnit.html) unit) Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do before the given timeout elapses. |
| \<T\> [RunnableFuture](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RunnableFuture.html)\<T\> | [newTaskFor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/AbstractExecutorService.html#newTaskFor(java.lang.Runnable,%20T))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) runnable, T value) Returns a `RunnableFuture` for the given runnable and default value. |
| \<T\> [RunnableFuture](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RunnableFuture.html)\<T\> | [newTaskFor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/AbstractExecutorService.html#newTaskFor(java.util.concurrent.Callable<T>))([Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\> callable) Returns a `RunnableFuture` for the given callable task. |
| \<T\> [Future](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html)\<T\> | [submit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/AbstractExecutorService.html#submit(java.util.concurrent.Callable<T>))([Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\> task) Submits a value-returning task for execution and returns a Future representing the pending results of the task. |
| \<T\> [Future](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html)\<T\> | [submit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/AbstractExecutorService.html#submit(java.lang.Runnable,%20T))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) task, T result) Submits a Runnable task for execution and returns a Future representing that task. |
| [Future](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html)\<?\> | [submit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/AbstractExecutorService.html#submit(java.lang.Runnable))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) task) Submits a Runnable task for execution and returns a Future representing that task. |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.util.concurrent.ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html)

|---|---|
| abstract boolean | [awaitTermination](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#awaitTermination(long,%20java.util.concurrent.TimeUnit))(long timeout, [TimeUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/TimeUnit.html) unit) Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first. |
| abstract \<T\> [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[Future](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html)\<T\>\> | [invokeAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#invokeAll(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\>\> tasks) Executes the given tasks, returning a list of Futures holding their status and results when all complete. |
| abstract \<T\> [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[Future](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html)\<T\>\> | [invokeAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#invokeAll(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>,%20long,%20java.util.concurrent.TimeUnit))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\>\> tasks, long timeout, [TimeUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/TimeUnit.html) unit) Executes the given tasks, returning a list of Futures holding their status and results when all complete or the timeout expires, whichever happens first. |
| abstract \<T\> T | [invokeAny](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#invokeAny(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\>\> tasks) Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do. |
| abstract \<T\> T | [invokeAny](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#invokeAny(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>,%20long,%20java.util.concurrent.TimeUnit))([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\>\> tasks, long timeout, [TimeUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/TimeUnit.html) unit) Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do before the given timeout elapses. |
| abstract boolean | [isShutdown](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#isShutdown())() Returns `true` if this executor has been shut down. |
| abstract boolean | [isTerminated](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#isTerminated())() Returns `true` if all tasks have completed following shut down. |
| abstract void | [shutdown](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#shutdown())() Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. |
| abstract [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html)\> | [shutdownNow](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#shutdownNow())() Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution. |
| abstract \<T\> [Future](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html)\<T\> | [submit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#submit(java.util.concurrent.Callable<T>))([Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\> task) Submits a value-returning task for execution and returns a Future representing the pending results of the task. |
| abstract \<T\> [Future](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html)\<T\> | [submit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#submit(java.lang.Runnable,%20T))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) task, T result) Submits a Runnable task for execution and returns a Future representing that task. |
| abstract [Future](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html)\<?\> | [submit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#submit(java.lang.Runnable))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) task) Submits a Runnable task for execution and returns a Future representing that task. |

From interface [java.util.concurrent.Executor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executor.html)

|---|---|
| abstract void | [execute](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executor.html#execute(java.lang.Runnable))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) command) Executes the given command at some time in the future. |

## Fields

#### public static final [ForkJoinPool.ForkJoinWorkerThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory.html)
**defaultForkJoinWorkerThreadFactory**

Creates a new ForkJoinWorkerThread. This factory is used unless
overridden in ForkJoinPool constructors.

## Public Constructors

#### public
**ForkJoinPool**
()

Creates a `ForkJoinPool` with parallelism equal to `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runtime.html#availableProcessors()`, using the {@linkplain #defaultForkJoinWorkerThreadFactory default thread factory},
no UncaughtExceptionHandler, and non-async LIFO processing mode.

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and the caller is not permitted to modify threads because it does not hold `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/RuntimePermission.html``("modifyThread")` |
|---|---|

#### public
**ForkJoinPool**
(int parallelism)

Creates a `ForkJoinPool` with the indicated parallelism
level, the {@linkplain #defaultForkJoinWorkerThreadFactory default thread factory},
no UncaughtExceptionHandler, and non-async LIFO processing mode.

##### Parameters

| parallelism | the parallelism level |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if parallelism less than or equal to zero, or greater than implementation limit |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and the caller is not permitted to modify threads because it does not hold `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/RuntimePermission.html``("modifyThread")` |
|---|---|

#### public
**ForkJoinPool**
(int parallelism, [ForkJoinPool.ForkJoinWorkerThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory.html) factory, Thread.UncaughtExceptionHandler handler, boolean asyncMode)

Creates a `ForkJoinPool` with the given parameters.

##### Parameters

| parallelism | the parallelism level. For default value, use `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runtime.html#availableProcessors()`. |
| factory | the factory for creating new threads. For default value, use `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#defaultForkJoinWorkerThreadFactory`. |
| handler | the handler for internal worker threads that terminate due to unrecoverable errors encountered while executing tasks. For default value, use `null`. |
| asyncMode | if true, establishes local first-in-first-out scheduling mode for forked tasks that are never joined. This mode may be more appropriate than default locally stack-based mode in applications in which worker threads only process event-style asynchronous tasks. For default value, use `false`. |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if parallelism less than or equal to zero, or greater than implementation limit |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the factory is null |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and the caller is not permitted to modify threads because it does not hold `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/RuntimePermission.html``("modifyThread")` |
|---|---|

## Public Methods

#### public boolean
**awaitQuiescence**
(long timeout, [TimeUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/TimeUnit.html) unit)

If called by a ForkJoinTask operating in this pool, equivalent
in effect to `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html#helpQuiesce()`. Otherwise,
waits and/or attempts to assist performing tasks until this
pool `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#isQuiescent()` or the indicated timeout elapses.

##### Parameters

| timeout | the maximum time to wait |
| unit | the time unit of the timeout argument |
|---|---|

##### Returns

- `true` if quiescent; `false` if the timeout elapsed.

#### public boolean
**awaitTermination**
(long timeout, [TimeUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/TimeUnit.html) unit)

Blocks until all tasks have completed execution after a
shutdown request, or the timeout occurs, or the current thread
is interrupted, whichever happens first. Because the `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#commonPool()` never terminates until program shutdown, when
applied to the common pool, this method is equivalent to `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#awaitQuiescence(long,%20java.util.concurrent.TimeUnit)` but always returns `false`.

##### Parameters

| timeout | the maximum time to wait |
| unit | the time unit of the timeout argument |
|---|---|

##### Returns

- `true` if this executor terminated and `false` if the timeout elapsed before termination

##### Throws

| [InterruptedException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/InterruptedException.html) | if interrupted while waiting |
|---|---|

#### public static [ForkJoinPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html)
**commonPool**
()

Returns the common pool instance. This pool is statically
constructed; its run state is unaffected by attempts to `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#shutdown()` or `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#shutdownNow()`. However this pool and any
ongoing processing are automatically terminated upon program
`https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/System.html#exit(int)`. Any program that relies on asynchronous
task processing to complete before program termination should
invoke `commonPool().``https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#awaitQuiescence(long,%20java.util.concurrent.TimeUnit)`,
before exit.

##### Returns

- the common pool instance

#### public void
**execute**
([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) task)

<br />

##### Parameters

| task |   |
|---|---|

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the task is null |
| [RejectedExecutionException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RejectedExecutionException.html) | if the task cannot be scheduled for execution |
|---|---|

#### public void
**execute**
([ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<?\> task)

Arranges for (asynchronous) execution of the given task.

##### Parameters

| task | the task |
|---|---|

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the task is null |
| [RejectedExecutionException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RejectedExecutionException.html) | if the task cannot be scheduled for execution |
|---|---|

#### public int
**getActiveThreadCount**
()

Returns an estimate of the number of threads that are currently
stealing or executing tasks. This method may overestimate the
number of active threads.

##### Returns

- the number of active threads

#### public boolean
**getAsyncMode**
()

Returns `true` if this pool uses local first-in-first-out
scheduling mode for forked tasks that are never joined.

##### Returns

- `true` if this pool uses async mode

#### public static int
**getCommonPoolParallelism**
()

Returns the targeted parallelism level of the common pool.

##### Returns

- the targeted parallelism level of the common pool

#### public [ForkJoinPool.ForkJoinWorkerThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory.html)
**getFactory**
()

Returns the factory used for constructing new workers.

##### Returns

- the factory used for constructing new workers

#### public int
**getParallelism**
()

Returns the targeted parallelism level of this pool.

##### Returns

- the targeted parallelism level of this pool

#### public int
**getPoolSize**
()

Returns the number of worker threads that have started but not
yet terminated. The result returned by this method may differ
from `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#getParallelism()` when threads are created to
maintain parallelism when others are cooperatively blocked.

##### Returns

- the number of worker threads

#### public int
**getQueuedSubmissionCount**
()

Returns an estimate of the number of tasks submitted to this
pool that have not yet begun executing. This method may take
time proportional to the number of submissions.

##### Returns

- the number of queued submissions

#### public long
**getQueuedTaskCount**
()

Returns an estimate of the total number of tasks currently held
in queues by worker threads (but not including tasks submitted
to the pool that have not begun executing). This value is only
an approximation, obtained by iterating across all threads in
the pool. This method may be useful for tuning task
granularities.

##### Returns

- the number of queued tasks

#### public int
**getRunningThreadCount**
()

Returns an estimate of the number of worker threads that are
not blocked waiting to join tasks or for other managed
synchronization. This method may overestimate the
number of running threads.

##### Returns

- the number of worker threads

#### public long
**getStealCount**
()

Returns an estimate of the total number of tasks stolen from
one thread's work queue by another. The reported value
underestimates the actual total number of steals when the pool
is not quiescent. This value may be useful for monitoring and
tuning fork/join programs: in general, steal counts should be
high enough to keep threads busy, but low enough to avoid
overhead and contention across threads.

##### Returns

- the number of steals

#### public Thread.UncaughtExceptionHandler
**getUncaughtExceptionHandler**
()

Returns the handler for internal worker threads that terminate
due to unrecoverable errors encountered while executing tasks.

##### Returns

- the handler, or `null` if none

#### public boolean
**hasQueuedSubmissions**
()

Returns `true` if there are any tasks submitted to this
pool that have not yet begun executing.

##### Returns

- `true` if there are any queued submissions

#### public T
**invoke**
([ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<T\> task)

Performs the given task, returning its result upon completion.
If the computation encounters an unchecked Exception or Error,
it is rethrown as the outcome of this invocation. Rethrown
exceptions behave in the same way as regular exceptions, but,
when possible, contain stack traces (as displayed for example
using `ex.printStackTrace()`) of both the current thread
as well as the thread actually encountering the exception;
minimally only the latter.

##### Parameters

| task | the task |
|---|---|

##### Returns

- the task's result

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the task is null |
| [RejectedExecutionException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RejectedExecutionException.html) | if the task cannot be scheduled for execution |
|---|---|

#### public [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[Future](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html)\<T\>\>
**invokeAll**
([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\>\> tasks)

Executes the given tasks, returning a list of Futures holding
their status and results when all complete.
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html#isDone()` is `true` for each
element of the returned list.
Note that a *completed* task could have
terminated either normally or by throwing an exception.
The results of this method are undefined if the given
collection is modified while this operation is in progress.

##### Parameters

| tasks | the collection of tasks |
|---|---|

##### Returns

- a list of Futures representing the tasks, in the same sequential order as produced by the iterator for the given task list, each of which has completed

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) |   |
| [RejectedExecutionException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RejectedExecutionException.html) |   |
|---|---|

#### public boolean
**isQuiescent**
()

Returns `true` if all worker threads are currently idle.
An idle worker is one that cannot obtain a task to execute
because none are available to steal from other threads, and
there are no pending submissions to the pool. This method is
conservative; it might not return `true` immediately upon
idleness of all threads, but will eventually become true if
threads remain inactive.

##### Returns

- `true` if all threads are currently idle

#### public boolean
**isShutdown**
()

Returns `true` if this pool has been shut down.

##### Returns

- `true` if this pool has been shut down

#### public boolean
**isTerminated**
()

Returns `true` if all tasks have completed following shut down.

##### Returns

- `true` if all tasks have completed following shut down

#### public boolean
**isTerminating**
()

Returns `true` if the process of termination has
commenced but not yet completed. This method may be useful for
debugging. A return of `true` reported a sufficient
period after shutdown may indicate that submitted tasks have
ignored or suppressed interruption, or are waiting for I/O,
causing this executor not to properly terminate. (See the
advisory notes for class `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html` stating that
tasks should not normally entail blocking operations. But if
they do, they must abort them on interrupt.)

##### Returns

- `true` if terminating but not yet terminated

#### public static void
**managedBlock**
([ForkJoinPool.ManagedBlocker](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.ManagedBlocker.html) blocker)

Runs the given possibly blocking task. When {@linkplain ForkJoinTask#inForkJoinPool() running in a ForkJoinPool}, this
method possibly arranges for a spare thread to be activated if
necessary to ensure sufficient parallelism while the current
thread is blocked in `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.ManagedBlocker.html#block()`.

This method repeatedly calls `blocker.isReleasable()` and
`blocker.block()` until either method returns `true`.
Every call to `blocker.block()` is preceded by a call to
`blocker.isReleasable()` that returned `false`.

If not running in a ForkJoinPool, this method is
behaviorally equivalent to

     while (!blocker.isReleasable())
       if (blocker.block())
         break;

If running in a ForkJoinPool, the pool may first be expanded to ensure sufficient parallelism available during the call to `blocker.block()`.

<br />

##### Parameters

| blocker | the blocker task |
|---|---|

##### Throws

| [InterruptedException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/InterruptedException.html) | if `blocker.block()` did so |
|---|---|

#### public void
**shutdown**
()

Possibly initiates an orderly shutdown in which previously
submitted tasks are executed, but no new tasks will be
accepted. Invocation has no effect on execution state if this
is the `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#commonPool()`, and no additional effect if
already shut down. Tasks that are in the process of being
submitted concurrently during the course of this method may or
may not be rejected.

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and the caller is not permitted to modify threads because it does not hold `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/RuntimePermission.html``("modifyThread")` |
|---|---|

#### public [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html)\>
**shutdownNow**
()

Possibly attempts to cancel and/or stop all tasks, and reject
all subsequently submitted tasks. Invocation has no effect on
execution state if this is the `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html#commonPool()`, and no
additional effect if already shut down. Otherwise, tasks that
are in the process of being submitted or executed concurrently
during the course of this method may or may not be
rejected. This method cancels both existing and unexecuted
tasks, in order to permit termination in the presence of task
dependencies. So the method always returns an empty list
(unlike the case for some other Executors).

##### Returns

- an empty list

##### Throws

| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and the caller is not permitted to modify threads because it does not hold `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/RuntimePermission.html``("modifyThread")` |
|---|---|

#### public [ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<T\>
**submit**
([Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\> task)

Submits a value-returning task for execution and returns a
Future representing the pending results of the task. The
Future's `get` method will return the task's result upon
successful completion.


If you would like to immediately block waiting
for a task, you can use constructions of the form
`result = exec.submit(aCallable).get();`

Note: The `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html` class includes a set of methods
that can convert some other common closure-like objects,
for example, `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedAction.html` to
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html` form so they can be submitted.

##### Parameters

| task | the task to submit |
|---|---|

##### Returns

- a Future representing pending completion of the task

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the task is null |
| [RejectedExecutionException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RejectedExecutionException.html) | if the task cannot be scheduled for execution |
|---|---|

#### public [ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<T\>
**submit**
([ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<T\> task)

Submits a ForkJoinTask for execution.

##### Parameters

| task | the task to submit |
|---|---|

##### Returns

- the task

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the task is null |
| [RejectedExecutionException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RejectedExecutionException.html) | if the task cannot be scheduled for execution |
|---|---|

#### public [ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<?\>
**submit**
([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) task)

Submits a Runnable task for execution and returns a Future
representing that task. The Future's `get` method will
return `null` upon *successful* completion.

##### Parameters

| task | the task to submit |
|---|---|

##### Returns

- a Future representing pending completion of the task

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the task is null |
| [RejectedExecutionException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RejectedExecutionException.html) | if the task cannot be scheduled for execution |
|---|---|

#### public [ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<T\>
**submit**
([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) task, T result)

Submits a Runnable task for execution and returns a Future
representing that task. The Future's `get` method will
return the given result upon successful completion.

##### Parameters

| task | the task to submit |
| result | the result to return |
|---|---|

##### Returns

- a Future representing pending completion of the task

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if the task is null |
| [RejectedExecutionException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RejectedExecutionException.html) | if the task cannot be scheduled for execution |
|---|---|

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**toString**
()

Returns a string identifying this pool, as well as its state,
including indications of run state, parallelism level, and
worker and task counts.

##### Returns

- a string identifying this pool, as well as its state

## Protected Methods

#### protected int
**drainTasksTo**
([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? super [ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<?\>\> c)

Removes all available unexecuted submitted and forked tasks
from scheduling queues and adds them to the given collection,
without altering their execution status. These may include
artificially generated or wrapped tasks. This method is
designed to be invoked only when the pool is known to be
quiescent. Invocations at other times may not remove all
tasks. A failure encountered while attempting to add elements
to collection `c` may result in elements being in
neither, either or both collections when the associated
exception is thrown. The behavior of this operation is
undefined if the specified collection is modified while the
operation is in progress.

##### Parameters

| c | the collection to transfer elements into |
|---|---|

##### Returns

- the number of elements transferred

#### protected [RunnableFuture](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RunnableFuture.html)\<T\>
**newTaskFor**
([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) runnable, T value)

Returns a `RunnableFuture` for the given runnable and default
value.

##### Parameters

| runnable | the runnable task being wrapped |
| value | the default value for the returned future |
|---|---|

##### Returns

- a `RunnableFuture` which, when run, will run the underlying runnable and which, as a `Future`, will yield the given value as its result and provide for cancellation of the underlying task

#### protected [RunnableFuture](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RunnableFuture.html)\<T\>
**newTaskFor**
([Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\> callable)

Returns a `RunnableFuture` for the given callable task.

##### Parameters

| callable | the callable task being wrapped |
|---|---|

##### Returns

- a `RunnableFuture` which, when run, will call the underlying callable and which, as a `Future`, will yield the callable's result as its result and provide for cancellation of the underlying task

#### protected [ForkJoinTask](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html)\<?\>
**pollSubmission**
()

Removes and returns the next unexecuted submission if one is
available. This method may be useful in extensions to this
class that re-assign work in systems with multiple pools.

##### Returns

- the next submission, or `null` if none