Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#nestedclasses) \| [Fields](https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#lfields) \| [Ctors](https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#pubctors) \| [Methods](https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#pubmethods) \| [Protected Methods](https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#promethods) \| [Inherited Methods](https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#inhmethods)

# ForkJoinPool


`
public


class
ForkJoinPool
`


`


`

`

extends https://developer.android.com/reference/java/util/concurrent/AbstractExecutorService


`

`


`

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [java.util.concurrent.AbstractExecutorService](https://developer.android.com/reference/java/util/concurrent/AbstractExecutorService) ||
|   | ↳ | java.util.concurrent.ForkJoinPool |

<br />

*** ** * ** ***

An `https://developer.android.com/reference/java/util/concurrent/ExecutorService` for running `https://developer.android.com/reference/java/util/concurrent/ForkJoinTask`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://developer.android.com/reference/java/util/concurrent/ExecutorService` 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. All worker threads are initialized
with `https://developer.android.com/reference/java/lang/Thread#isDaemon()` set `true`.

A static `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#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://developer.android.com/reference/java/util/concurrent/ForkJoinPool.ManagedBlocker` interface enables extension of the kinds of
synchronization accommodated. The default policies may be
overridden using a constructor with parameters corresponding to
those documented in class `https://developer.android.com/reference/java/util/concurrent/ThreadPoolExecutor`.

In addition to execution and lifecycle control methods, this
class provides status check methods (for example
`https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#getStealCount()`) that are intended to aid in developing,
tuning, and monitoring fork/join applications. Also, method
`https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#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 |
[Summary of task execution methods]

The parameters used to construct the common pool may be controlled by
setting the following [system properties](https://developer.android.com/reference/java/lang/System#getProperty(java.lang.String)):

- `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://developer.android.com/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory`. The [system class loader](https://developer.android.com/reference/java/lang/ClassLoader#getSystemClassLoader()) is used to load this class.
- `java.util.concurrent.ForkJoinPool.common.exceptionHandler` - the class name of a `https://developer.android.com/reference/java/lang/Thread.UncaughtExceptionHandler`. The [system class loader](https://developer.android.com/reference/java/lang/ClassLoader#getSystemClassLoader()) is used to load this class.
- `java.util.concurrent.ForkJoinPool.common.maximumSpares` - the maximum number of allowed extra threads to maintain target parallelism (default 256).

If no thread factory is supplied via a system property, then the common pool uses a factory that uses the system class loader as the [thread context class loader](https://developer.android.com/reference/java/lang/Thread#getContextClassLoader()). In addition, if a `https://developer.android.com/reference/java/lang/SecurityManager` is present, then the common pool uses a factory supplying threads that have no `https://developer.android.com/reference/java/security/Permissions` enabled, and are not guaranteed to preserve the values of `https://developer.android.com/reference/java/lang/ThreadLocal` variables across tasks. 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.

<br />

## Summary

| ### Nested classes ||
|---|---|
| ` interface` | `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory` Factory for creating new `https://developer.android.com/reference/java/util/concurrent/ForkJoinWorkerThread`s. |
| ` interface` | `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool.ManagedBlocker` Interface for extending managed parallelism for tasks running in `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool`s. |

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory` | `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#defaultForkJoinWorkerThreadFactory` Creates a new ForkJoinWorkerThread. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#ForkJoinPool()() ` Creates a `ForkJoinPool` with parallelism equal to `https://developer.android.com/reference/java/lang/Runtime#availableProcessors()`, using defaults for all other parameters (see `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#ForkJoinPool(int,%20java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory,%20java.lang.Thread.UncaughtExceptionHandler,%20boolean,%20int,%20int,%20int,%20java.util.function.Predicate<?%20super%20java.util.concurrent.ForkJoinPool>,%20long,%20java.util.concurrent.TimeUnit)`). |
| ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#ForkJoinPool(int)(int parallelism) ` Creates a `ForkJoinPool` with the indicated parallelism level, using defaults for all other parameters (see `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#ForkJoinPool(int,%20java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory,%20java.lang.Thread.UncaughtExceptionHandler,%20boolean,%20int,%20int,%20int,%20java.util.function.Predicate<?%20super%20java.util.concurrent.ForkJoinPool>,%20long,%20java.util.concurrent.TimeUnit)`). |
| ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#ForkJoinPool(int,%20java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory,%20java.lang.Thread.UncaughtExceptionHandler,%20boolean)(int parallelism, https://developer.android.com/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory factory, https://developer.android.com/reference/java/lang/Thread.UncaughtExceptionHandler handler, boolean asyncMode) ` Creates a `ForkJoinPool` with the given parameters (using defaults for others -- see `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#ForkJoinPool(int,%20java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory,%20java.lang.Thread.UncaughtExceptionHandler,%20boolean,%20int,%20int,%20int,%20java.util.function.Predicate<?%20super%20java.util.concurrent.ForkJoinPool>,%20long,%20java.util.concurrent.TimeUnit)`). |
| ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#ForkJoinPool(int,%20java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory,%20java.lang.Thread.UncaughtExceptionHandler,%20boolean,%20int,%20int,%20int,%20java.util.function.Predicate<?%20super%20java.util.concurrent.ForkJoinPool>,%20long,%20java.util.concurrent.TimeUnit)(int parallelism, https://developer.android.com/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory factory, https://developer.android.com/reference/java/lang/Thread.UncaughtExceptionHandler handler, boolean asyncMode, int corePoolSize, int maximumPoolSize, int minimumRunnable, https://developer.android.com/reference/java/util/function/Predicate<? super https://developer.android.com/reference/java/util/concurrent/ForkJoinPool> saturate, long keepAliveTime, https://developer.android.com/reference/java/util/concurrent/TimeUnit unit) ` Creates a `ForkJoinPool` with the given parameters. |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#awaitQuiescence(long,%20java.util.concurrent.TimeUnit)(long timeout, https://developer.android.com/reference/java/util/concurrent/TimeUnit unit) ` If called by a ForkJoinTask operating in this pool, equivalent in effect to `https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#helpQuiesce()`. |
| ` boolean` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#awaitTermination(long,%20java.util.concurrent.TimeUnit)(long timeout, https://developer.android.com/reference/java/util/concurrent/TimeUnit 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. |
| ` void` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#close()() ` Unless this is the `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#commonPool()`, initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted, and waits until all tasks have completed execution and the executor has terminated. |
| ` static https://developer.android.com/reference/java/util/concurrent/ForkJoinPool` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#commonPool()() ` Returns the common pool instance. |
| ` void` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#execute(java.lang.Runnable)(https://developer.android.com/reference/java/lang/Runnable task) ` |
| ` void` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#execute(java.util.concurrent.ForkJoinTask<?>)(https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<?> task) ` Arranges for (asynchronous) execution of the given task. |
| ` <T> https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T>` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#externalSubmit(java.util.concurrent.ForkJoinTask<T>)(https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T> task) ` Submits the given task as if submitted from a non-`ForkJoinTask` client. |
| ` int` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#getActiveThreadCount()() ` Returns an estimate of the number of threads that are currently stealing or executing tasks. |
| ` boolean` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#getAsyncMode()() ` Returns `true` if this pool uses local first-in-first-out scheduling mode for forked tasks that are never joined. |
| ` static int` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#getCommonPoolParallelism()() ` Returns the targeted parallelism level of the common pool. |
| ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#getFactory()() ` Returns the factory used for constructing new workers. |
| ` int` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#getParallelism()() ` Returns the targeted parallelism level of this pool. |
| ` int` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#getPoolSize()() ` Returns the number of worker threads that have started but not yet terminated. |
| ` int` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#getQueuedSubmissionCount()() ` Returns an estimate of the number of tasks submitted to this pool that have not yet begun executing. |
| ` long` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#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` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#getRunningThreadCount()() ` Returns an estimate of the number of worker threads that are not blocked waiting to join tasks or for other managed synchronization. |
| ` long` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#getStealCount()() ` Returns an estimate of the total number of completed tasks that were executed by a thread other than their submitter. |
| ` https://developer.android.com/reference/java/lang/Thread.UncaughtExceptionHandler` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#getUncaughtExceptionHandler()() ` Returns the handler for internal worker threads that terminate due to unrecoverable errors encountered while executing tasks. |
| ` boolean` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#hasQueuedSubmissions()() ` Returns `true` if there are any tasks submitted to this pool that have not yet begun executing. |
| ` <T> T` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#invoke(java.util.concurrent.ForkJoinTask<T>)(https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T> task) ` Performs the given task, returning its result upon completion. |
| ` <T> https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/util/concurrent/Future<T>>` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#invokeAll(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>,%20long,%20java.util.concurrent.TimeUnit)(https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/util/concurrent/Callable<T>> tasks, long timeout, https://developer.android.com/reference/java/util/concurrent/TimeUnit 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> https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/util/concurrent/Future<T>>` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#invokeAll(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>)(https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/util/concurrent/Callable<T>> tasks) ` Executes the given tasks, returning a list of Futures holding their status and results when all complete. |
| ` <T> T` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#invokeAny(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>)(https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/util/concurrent/Callable<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` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#invokeAny(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>,%20long,%20java.util.concurrent.TimeUnit)(https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/util/concurrent/Callable<T>> tasks, long timeout, https://developer.android.com/reference/java/util/concurrent/TimeUnit 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. |
| ` boolean` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#isQuiescent()() ` Returns `true` if all worker threads are currently idle. |
| ` boolean` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#isShutdown()() ` Returns `true` if this pool has been shut down. |
| ` boolean` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#isTerminated()() ` Returns `true` if all tasks have completed following shut down. |
| ` boolean` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#isTerminating()() ` Returns `true` if the process of termination has commenced but not yet completed. |
| ` <T> https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T>` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#lazySubmit(java.util.concurrent.ForkJoinTask<T>)(https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T> task) ` Submits the given task without guaranteeing that it will eventually execute in the absence of available active threads. |
| ` static void` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#managedBlock(java.util.concurrent.ForkJoinPool.ManagedBlocker)(https://developer.android.com/reference/java/util/concurrent/ForkJoinPool.ManagedBlocker blocker) ` Runs the given possibly blocking task. |
| ` int` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#setParallelism(int)(int size) ` Changes the target parallelism of this pool, controlling the future creation, use, and termination of worker threads. |
| ` void` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#shutdown()() ` Possibly initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/Runnable>` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#shutdownNow()() ` Possibly attempts to cancel and/or stop all tasks, and reject all subsequently submitted tasks. |
| ` <T> https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T>` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#submit(java.util.concurrent.Callable<T>)(https://developer.android.com/reference/java/util/concurrent/Callable<T> task) ` Submits a value-returning task for execution and returns a Future representing the pending results of the task. |
| ` <T> https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T>` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#submit(java.util.concurrent.ForkJoinTask<T>)(https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T> task) ` Submits a ForkJoinTask for execution. |
| ` https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<?>` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#submit(java.lang.Runnable)(https://developer.android.com/reference/java/lang/Runnable task) ` Submits a Runnable task for execution and returns a Future representing that task. |
| ` <T> https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T>` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#submit(java.lang.Runnable,%20T)(https://developer.android.com/reference/java/lang/Runnable task, T result) ` Submits a Runnable task for execution and returns a Future representing that task. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#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 methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#drainTasksTo(java.util.Collection<?%20super%20java.util.concurrent.ForkJoinTask<?>>)(https://developer.android.com/reference/java/util/Collection<? super https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<?>> 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> https://developer.android.com/reference/java/util/concurrent/RunnableFuture<T>` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#newTaskFor(java.lang.Runnable,%20T)(https://developer.android.com/reference/java/lang/Runnable runnable, T value) ` Returns a `RunnableFuture` for the given runnable and default value. |
| ` <T> https://developer.android.com/reference/java/util/concurrent/RunnableFuture<T>` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#newTaskFor(java.util.concurrent.Callable<T>)(https://developer.android.com/reference/java/util/concurrent/Callable<T> callable) ` Returns a `RunnableFuture` for the given callable task. |
| ` https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<?>` | ` https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#pollSubmission()() ` Removes and returns the next unexecuted submission if one is available. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/util/concurrent/AbstractExecutorService ` |---|---| | ` <T> https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/util/concurrent/Future<T>>` | ` https://developer.android.com/reference/java/util/concurrent/AbstractExecutorService#invokeAll(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>)(https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/util/concurrent/Callable<T>> tasks) ` Executes the given tasks, returning a list of Futures holding their status and results when all complete. | | ` <T> https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/util/concurrent/Future<T>>` | ` https://developer.android.com/reference/java/util/concurrent/AbstractExecutorService#invokeAll(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>,%20long,%20java.util.concurrent.TimeUnit)(https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/util/concurrent/Callable<T>> tasks, long timeout, https://developer.android.com/reference/java/util/concurrent/TimeUnit 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` | ` https://developer.android.com/reference/java/util/concurrent/AbstractExecutorService#invokeAny(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>)(https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/util/concurrent/Callable<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` | ` https://developer.android.com/reference/java/util/concurrent/AbstractExecutorService#invokeAny(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>,%20long,%20java.util.concurrent.TimeUnit)(https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/util/concurrent/Callable<T>> tasks, long timeout, https://developer.android.com/reference/java/util/concurrent/TimeUnit 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> https://developer.android.com/reference/java/util/concurrent/RunnableFuture<T>` | ` https://developer.android.com/reference/java/util/concurrent/AbstractExecutorService#newTaskFor(java.lang.Runnable,%20T)(https://developer.android.com/reference/java/lang/Runnable runnable, T value) ` Returns a `RunnableFuture` for the given runnable and default value. | | ` <T> https://developer.android.com/reference/java/util/concurrent/RunnableFuture<T>` | ` https://developer.android.com/reference/java/util/concurrent/AbstractExecutorService#newTaskFor(java.util.concurrent.Callable<T>)(https://developer.android.com/reference/java/util/concurrent/Callable<T> callable) ` Returns a `RunnableFuture` for the given callable task. | | ` <T> https://developer.android.com/reference/java/util/concurrent/Future<T>` | ` https://developer.android.com/reference/java/util/concurrent/AbstractExecutorService#submit(java.util.concurrent.Callable<T>)(https://developer.android.com/reference/java/util/concurrent/Callable<T> task) ` Submits a value-returning task for execution and returns a Future representing the pending results of the task. | | ` <T> https://developer.android.com/reference/java/util/concurrent/Future<T>` | ` https://developer.android.com/reference/java/util/concurrent/AbstractExecutorService#submit(java.lang.Runnable,%20T)(https://developer.android.com/reference/java/lang/Runnable task, T result) ` Submits a Runnable task for execution and returns a Future representing that task. | | ` https://developer.android.com/reference/java/util/concurrent/Future<?>` | ` https://developer.android.com/reference/java/util/concurrent/AbstractExecutorService#submit(java.lang.Runnable)(https://developer.android.com/reference/java/lang/Runnable task) ` Submits a Runnable task for execution and returns a Future representing that task. | ||
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||
| From interface ` https://developer.android.com/reference/java/util/concurrent/ExecutorService ` |---|---| | ` abstract boolean` | ` https://developer.android.com/reference/java/util/concurrent/ExecutorService#awaitTermination(long,%20java.util.concurrent.TimeUnit)(long timeout, https://developer.android.com/reference/java/util/concurrent/TimeUnit 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. | | ` default void` | ` https://developer.android.com/reference/java/util/concurrent/ExecutorService#close()() ` Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. | | ` abstract <T> https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/util/concurrent/Future<T>>` | ` https://developer.android.com/reference/java/util/concurrent/ExecutorService#invokeAll(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>)(https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/util/concurrent/Callable<T>> tasks) ` Executes the given tasks, returning a list of Futures holding their status and results when all complete. | | ` abstract <T> https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/util/concurrent/Future<T>>` | ` https://developer.android.com/reference/java/util/concurrent/ExecutorService#invokeAll(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>,%20long,%20java.util.concurrent.TimeUnit)(https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/util/concurrent/Callable<T>> tasks, long timeout, https://developer.android.com/reference/java/util/concurrent/TimeUnit 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` | ` https://developer.android.com/reference/java/util/concurrent/ExecutorService#invokeAny(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>)(https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/util/concurrent/Callable<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` | ` https://developer.android.com/reference/java/util/concurrent/ExecutorService#invokeAny(java.util.Collection<?%20extends%20java.util.concurrent.Callable<T>>,%20long,%20java.util.concurrent.TimeUnit)(https://developer.android.com/reference/java/util/Collection<? extends https://developer.android.com/reference/java/util/concurrent/Callable<T>> tasks, long timeout, https://developer.android.com/reference/java/util/concurrent/TimeUnit 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` | ` https://developer.android.com/reference/java/util/concurrent/ExecutorService#isShutdown()() ` Returns `true` if this executor has been shut down. | | ` abstract boolean` | ` https://developer.android.com/reference/java/util/concurrent/ExecutorService#isTerminated()() ` Returns `true` if all tasks have completed following shut down. | | ` abstract void` | ` https://developer.android.com/reference/java/util/concurrent/ExecutorService#shutdown()() ` Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. | | ` abstract https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/Runnable>` | ` https://developer.android.com/reference/java/util/concurrent/ExecutorService#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 https://developer.android.com/reference/java/util/concurrent/Future<?>` | ` https://developer.android.com/reference/java/util/concurrent/ExecutorService#submit(java.lang.Runnable)(https://developer.android.com/reference/java/lang/Runnable task) ` Submits a Runnable task for execution and returns a Future representing that task. | | ` abstract <T> https://developer.android.com/reference/java/util/concurrent/Future<T>` | ` https://developer.android.com/reference/java/util/concurrent/ExecutorService#submit(java.util.concurrent.Callable<T>)(https://developer.android.com/reference/java/util/concurrent/Callable<T> task) ` Submits a value-returning task for execution and returns a Future representing the pending results of the task. | | ` abstract <T> https://developer.android.com/reference/java/util/concurrent/Future<T>` | ` https://developer.android.com/reference/java/util/concurrent/ExecutorService#submit(java.lang.Runnable,%20T)(https://developer.android.com/reference/java/lang/Runnable task, T result) ` Submits a Runnable task for execution and returns a Future representing that task. | ||
| From interface ` https://developer.android.com/reference/java/lang/AutoCloseable ` |---|---| | ` abstract void` | ` https://developer.android.com/reference/java/lang/AutoCloseable#close()() ` Closes this resource, relinquishing any underlying resources. | ||
| From interface ` https://developer.android.com/reference/java/util/concurrent/Executor ` |---|---| | ` abstract void` | ` https://developer.android.com/reference/java/util/concurrent/Executor#execute(java.lang.Runnable)(https://developer.android.com/reference/java/lang/Runnable command) ` Executes the given command at some time in the future. | ||

## Fields

### defaultForkJoinWorkerThreadFactory

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final ForkJoinPool.ForkJoinWorkerThreadFactory defaultForkJoinWorkerThreadFactory
```

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

<br />

## Public constructors

### ForkJoinPool

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ForkJoinPool ()
```

Creates a `ForkJoinPool` with parallelism equal to `https://developer.android.com/reference/java/lang/Runtime#availableProcessors()`, using defaults for all
other parameters (see `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#ForkJoinPool(int,%20java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory,%20java.lang.Thread.UncaughtExceptionHandler,%20boolean,%20int,%20int,%20int,%20java.util.function.Predicate<?%20super%20java.util.concurrent.ForkJoinPool>,%20long,%20java.util.concurrent.TimeUnit)`).

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException` | if a security manager exists and the caller is not permitted to modify threads because it does not hold `https://developer.android.com/reference/java/lang/RuntimePermission``("modifyThread")` |

### ForkJoinPool

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ForkJoinPool (int parallelism)
```

Creates a `ForkJoinPool` with the indicated parallelism
level, using defaults for all other parameters (see `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#ForkJoinPool(int,%20java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory,%20java.lang.Thread.UncaughtExceptionHandler,%20boolean,%20int,%20int,%20int,%20java.util.function.Predicate<?%20super%20java.util.concurrent.ForkJoinPool>,%20long,%20java.util.concurrent.TimeUnit)`).

<br />

| Parameters ||
|---|---|
| `parallelism` | `int`: the parallelism level <br /> |

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

### ForkJoinPool

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ForkJoinPool (int parallelism, 
                ForkJoinPool.ForkJoinWorkerThreadFactory factory, 
                Thread.UncaughtExceptionHandler handler, 
                boolean asyncMode)
```

Creates a `ForkJoinPool` with the given parameters (using
defaults for others -- see `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#ForkJoinPool(int,%20java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory,%20java.lang.Thread.UncaughtExceptionHandler,%20boolean,%20int,%20int,%20int,%20java.util.function.Predicate<?%20super%20java.util.concurrent.ForkJoinPool>,%20long,%20java.util.concurrent.TimeUnit)`).

<br />

| Parameters ||
|---|---|
| `parallelism` | `int`: the parallelism level. For default value, use `https://developer.android.com/reference/java/lang/Runtime#availableProcessors()`. <br /> |
| `factory` | `ForkJoinPool.ForkJoinWorkerThreadFactory`: the factory for creating new threads. For default value, use `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#defaultForkJoinWorkerThreadFactory`. <br /> |
| `handler` | `Thread.UncaughtExceptionHandler`: the handler for internal worker threads that terminate due to unrecoverable errors encountered while executing tasks. For default value, use `null`. <br /> |
| `asyncMode` | `boolean`: 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`. <br /> |

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

### ForkJoinPool

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ForkJoinPool (int parallelism, 
                ForkJoinPool.ForkJoinWorkerThreadFactory factory, 
                Thread.UncaughtExceptionHandler handler, 
                boolean asyncMode, 
                int corePoolSize, 
                int maximumPoolSize, 
                int minimumRunnable, 
                Predicate<? super ForkJoinPool> saturate, 
                long keepAliveTime, 
                TimeUnit unit)
```

Creates a `ForkJoinPool` with the given parameters.

<br />

| Parameters ||
|---|---|
| `parallelism` | `int`: the parallelism level. For default value, use `https://developer.android.com/reference/java/lang/Runtime#availableProcessors()`. <br /> |
| `factory` | `ForkJoinPool.ForkJoinWorkerThreadFactory`: the factory for creating new threads. For default value, use `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#defaultForkJoinWorkerThreadFactory`. <br /> |
| `handler` | `Thread.UncaughtExceptionHandler`: the handler for internal worker threads that terminate due to unrecoverable errors encountered while executing tasks. For default value, use `null`. <br /> |
| `asyncMode` | `boolean`: 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`. <br /> |
| `corePoolSize` | `int`: the number of threads to keep in the pool (unless timed out after an elapsed keep-alive). Normally (and by default) this is the same value as the parallelism level, but may be set to a larger value to reduce dynamic overhead if tasks regularly block. Using a smaller value (for example `0`) has the same effect as the default. <br /> |
| `maximumPoolSize` | `int`: the maximum number of threads allowed. When the maximum is reached, attempts to replace blocked threads fail. (However, because creation and termination of different threads may overlap, and may be managed by the given thread factory, this value may be transiently exceeded.) To arrange the same value as is used by default for the common pool, use `256` plus the `parallelism` level. (By default, the common pool allows a maximum of 256 spare threads.) Using a value (for example `Integer.MAX_VALUE`) larger than the implementation's total thread limit has the same effect as using this limit (which is the default). <br /> |
| `minimumRunnable` | `int`: the minimum allowed number of core threads not blocked by a join or `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool.ManagedBlocker`. To ensure progress, when too few unblocked threads exist and unexecuted tasks may exist, new threads are constructed, up to the given maximumPoolSize. For the default value, use `1`, that ensures liveness. A larger value might improve throughput in the presence of blocked activities, but might not, due to increased overhead. A value of zero may be acceptable when submitted tasks cannot have dependencies requiring additional threads. <br /> |
| `saturate` | `Predicate`: if non-null, a predicate invoked upon attempts to create more than the maximum total allowed threads. By default, when a thread is about to block on a join or `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool.ManagedBlocker`, but cannot be replaced because the maximumPoolSize would be exceeded, a `https://developer.android.com/reference/java/util/concurrent/RejectedExecutionException` is thrown. But if this predicate returns `true`, then no exception is thrown, so the pool continues to operate with fewer than the target number of runnable threads, which might not ensure progress. <br /> |
| `keepAliveTime` | `long`: the elapsed time since last use before a thread is terminated (and then later replaced if needed). For the default value, use `60, TimeUnit.SECONDS`. <br /> |
| `unit` | `TimeUnit`: the time unit for the `keepAliveTime` argument <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if parallelism is less than or equal to zero, or is greater than implementation limit, or if maximumPoolSize is less than parallelism, of if the keepAliveTime is less than or equal to zero. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the factory is null |
| `https://developer.android.com/reference/java/lang/SecurityException` | if a security manager exists and the caller is not permitted to modify threads because it does not hold `https://developer.android.com/reference/java/lang/RuntimePermission``("modifyThread")` |

## Public methods

### awaitQuiescence

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean awaitQuiescence (long timeout, 
                TimeUnit unit)
```

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

<br />

| Parameters ||
|---|---|
| `timeout` | `long`: the maximum time to wait <br /> |
| `unit` | `TimeUnit`: the time unit of the timeout argument <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if quiescent; `false` if the timeout elapsed. <br /> |

### awaitTermination

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean awaitTermination (long timeout, 
                TimeUnit 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://developer.android.com/reference/java/util/concurrent/ForkJoinPool#commonPool()` never terminates until program shutdown, when
applied to the common pool, this method is equivalent to `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#awaitQuiescence(long,%20java.util.concurrent.TimeUnit)` but always returns `false`.

<br />

| Parameters ||
|---|---|
| `timeout` | `long`: the maximum time to wait <br /> |
| `unit` | `TimeUnit`: the time unit of the timeout argument <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this executor terminated and `false` if the timeout elapsed before termination <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/InterruptedException` | if interrupted while waiting |

### close

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void close ()
```

Unless this is the `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#commonPool()`, initiates an orderly
shutdown in which previously submitted tasks are executed, but
no new tasks will be accepted, and waits until all tasks have
completed execution and the executor has terminated.

If already terminated, or this is the `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#commonPool()`, this method has no effect on execution, and
does not wait. Otherwise, if interrupted while waiting, this
method stops all executing tasks as if by invoking `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#shutdownNow()`. It then continues to wait until all actively
executing tasks have completed. Tasks that were awaiting
execution are not executed. The interrupt status will be
re-asserted before this method returns.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException` | if a security manager exists and shutting down this ExecutorService may manipulate threads that the caller is not permitted to modify because it does not hold `https://developer.android.com/reference/java/lang/RuntimePermission``("modifyThread")`, or the security manager's `checkAccess` method denies access. |

### commonPool

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static ForkJoinPool commonPool ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool` | the common pool instance <br /> |

### execute

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void execute (Runnable task)
```

<br />

<br />

| Parameters ||
|---|---|
| `task` | `Runnable` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the task is null |
| `https://developer.android.com/reference/java/util/concurrent/RejectedExecutionException` | if the task cannot be scheduled for execution |

### execute

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void execute (ForkJoinTask<?> task)
```

Arranges for (asynchronous) execution of the given task.

<br />

| Parameters ||
|---|---|
| `task` | `ForkJoinTask`: the task <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the task is null |
| `https://developer.android.com/reference/java/util/concurrent/RejectedExecutionException` | if the task cannot be scheduled for execution |

### externalSubmit

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ForkJoinTask<T> externalSubmit (ForkJoinTask<T> task)
```

Submits the given task as if submitted from a non-`ForkJoinTask`
client. The task is added to a scheduling queue for submissions to the
pool even when called from a thread in the pool.

<br />

##### Implementation Requirements:

- This method is equivalent to `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#submit(java.util.concurrent.ForkJoinTask<T>)` when called from a thread that is not in this pool.

| Parameters ||
|---|---|
| `task` | `ForkJoinTask`: the task to submit <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T>` | the task <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the task is null |
| `https://developer.android.com/reference/java/util/concurrent/RejectedExecutionException` | if the task cannot be scheduled for execution |

### getActiveThreadCount

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Returns ||
|---|---|
| `int` | the number of active threads <br /> |

### getAsyncMode

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean getAsyncMode ()
```

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

<br />

| Returns ||
|---|---|
| `boolean` | `true` if this pool uses async mode <br /> |

### getCommonPoolParallelism

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getCommonPoolParallelism ()
```

Returns the targeted parallelism level of the common pool.

<br />

| Returns ||
|---|---|
| `int` | the targeted parallelism level of the common pool <br /> |

### getFactory

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ForkJoinPool.ForkJoinWorkerThreadFactory getFactory ()
```

Returns the factory used for constructing new workers.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool.ForkJoinWorkerThreadFactory` | the factory used for constructing new workers <br /> |

### getParallelism

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getParallelism ()
```

Returns the targeted parallelism level of this pool.

<br />

| Returns ||
|---|---|
| `int` | the targeted parallelism level of this pool <br /> |

### getPoolSize

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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://developer.android.com/reference/java/util/concurrent/ForkJoinPool#getParallelism()` when threads are created to
maintain parallelism when others are cooperatively blocked.

<br />

| Returns ||
|---|---|
| `int` | the number of worker threads <br /> |

### getQueuedSubmissionCount

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Returns ||
|---|---|
| `int` | the number of queued submissions <br /> |

### getQueuedTaskCount

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Returns ||
|---|---|
| `long` | the number of queued tasks <br /> |

**See also:**

- `https://developer.android.com/reference/java/util/concurrent/ForkJoinWorkerThread#getQueuedTaskCount()`

### getRunningThreadCount

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Returns ||
|---|---|
| `int` | the number of worker threads <br /> |

### getStealCount

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long getStealCount ()
```

Returns an estimate of the total number of completed tasks that
were executed by a thread other than their submitter. 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.

<br />

| Returns ||
|---|---|
| `long` | the number of steals <br /> |

### getUncaughtExceptionHandler

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Thread.UncaughtExceptionHandler getUncaughtExceptionHandler ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Thread.UncaughtExceptionHandler` | the handler, or `null` if none <br /> |

### hasQueuedSubmissions

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean hasQueuedSubmissions ()
```

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

<br />

| Returns ||
|---|---|
| `boolean` | `true` if there are any queued submissions <br /> |

### invoke

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public T invoke (ForkJoinTask<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.

<br />

| Parameters ||
|---|---|
| `task` | `ForkJoinTask`: the task <br /> |

| Returns ||
|---|---|
| `T` | the task's result <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the task is null |
| `https://developer.android.com/reference/java/util/concurrent/RejectedExecutionException` | if the task cannot be scheduled for execution |

### invokeAll

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public List<Future<T>> invokeAll (Collection<? extends Callable<T>> tasks, 
                long timeout, 
                TimeUnit 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.
`https://developer.android.com/reference/java/util/concurrent/Future#isDone()` is `true` for each
element of the returned list.
Upon return, tasks that have not completed are cancelled.
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.

<br />

| Parameters ||
|---|---|
| `tasks` | `Collection`: the collection of tasks <br /> |
| `timeout` | `long`: the maximum time to wait <br /> |
| `unit` | `TimeUnit`: the time unit of the timeout argument <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/util/concurrent/Future<T>>` | a list of Futures representing the tasks, in the same sequential order as produced by the iterator for the given task list. If the operation did not time out, each task will have completed. If it did time out, some of these tasks will not have completed. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/InterruptedException` |   |

### invokeAll

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public List<Future<T>> invokeAll (Collection<? extends Callable<T>> tasks)
```

Executes the given tasks, returning a list of Futures holding
their status and results when all complete.
`https://developer.android.com/reference/java/util/concurrent/Future#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.

<br />

| Parameters ||
|---|---|
| `tasks` | `Collection`: the collection of tasks <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/util/concurrent/Future<T>>` | 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 <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` |   |
| `https://developer.android.com/reference/java/util/concurrent/RejectedExecutionException` |   |

### invokeAny

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public T invokeAny (Collection<? extends Callable<T>> tasks)
```

Executes the given tasks, returning the result
of one that has completed successfully (i.e., without throwing
an exception), if any do. Upon normal or exceptional return,
tasks that have not completed are cancelled.
The results of this method are undefined if the given
collection is modified while this operation is in progress.

<br />

| Parameters ||
|---|---|
| `tasks` | `Collection`: the collection of tasks <br /> |

| Returns ||
|---|---|
| `T` | the result returned by one of the tasks <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ExecutionException` |   |
| `https://developer.android.com/reference/java/lang/InterruptedException` |   |

### invokeAny

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public T invokeAny (Collection<? extends Callable<T>> tasks, 
                long timeout, 
                TimeUnit 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.
Upon normal or exceptional return, tasks that have not
completed are cancelled.
The results of this method are undefined if the given
collection is modified while this operation is in progress.

<br />

| Parameters ||
|---|---|
| `tasks` | `Collection`: the collection of tasks <br /> |
| `timeout` | `long`: the maximum time to wait <br /> |
| `unit` | `TimeUnit`: the time unit of the timeout argument <br /> |

| Returns ||
|---|---|
| `T` | the result returned by one of the tasks <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ExecutionException` |   |
| `https://developer.android.com/reference/java/lang/InterruptedException` |   |
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException` |   |

### isQuiescent

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if all threads are currently idle <br /> |

### isShutdown

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isShutdown ()
```

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

<br />

| Returns ||
|---|---|
| `boolean` | `true` if this pool has been shut down <br /> |

### isTerminated

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isTerminated ()
```

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

<br />

| Returns ||
|---|---|
| `boolean` | `true` if all tasks have completed following shut down <br /> |

### isTerminating

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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://developer.android.com/reference/java/util/concurrent/ForkJoinTask` stating that
tasks should not normally entail blocking operations. But if
they do, they must abort them on interrupt.)

<br />

| Returns ||
|---|---|
| `boolean` | `true` if terminating but not yet terminated <br /> |

### lazySubmit

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ForkJoinTask<T> lazySubmit (ForkJoinTask<T> task)
```

Submits the given task without guaranteeing that it will
eventually execute in the absence of available active threads.
In some contexts, this method may reduce contention and
overhead by relying on context-specific knowledge that existing
threads (possibly including the calling thread if operating in
this pool) will eventually be available to execute the task.

<br />

| Parameters ||
|---|---|
| `task` | `ForkJoinTask`: the task <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T>` | the task <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the task is null |
| `https://developer.android.com/reference/java/util/concurrent/RejectedExecutionException` | if the task cannot be scheduled for execution |

### managedBlock

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void managedBlock (ForkJoinPool.ManagedBlocker blocker)
```

Runs the given possibly blocking task. When [running in a ForkJoinPool](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#inForkJoinPool()), 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://developer.android.com/reference/java/util/concurrent/ForkJoinPool.ManagedBlocker#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 />

<br />

| Parameters ||
|---|---|
| `blocker` | `ForkJoinPool.ManagedBlocker`: the blocker task <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/InterruptedException` | if `blocker.block()` did so |

### setParallelism

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int setParallelism (int size)
```

Changes the target parallelism of this pool, controlling the
future creation, use, and termination of worker threads.
Applications include contexts in which the number of available
processors changes over time.

<br />

##### Implementation Note:

- This implementation restricts the maximum number of running threads to 32767

| Parameters ||
|---|---|
| `size` | `int`: the target parallelism level <br /> |

| Returns ||
|---|---|
| `int` | the previous parallelism level. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if size is less than 1 or greater than the maximum supported by this pool. |
| `https://developer.android.com/reference/java/lang/SecurityException` | if a security manager exists and the caller is not permitted to modify threads because it does not hold `https://developer.android.com/reference/java/lang/RuntimePermission``("modifyThread")` |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | this is the`https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#commonPool()` and parallelism level was set by System property {@systemProperty java.util.concurrent.ForkJoinPool.common.parallelism}. |

### shutdown

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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://developer.android.com/reference/java/util/concurrent/ForkJoinPool#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.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException` | if a security manager exists and the caller is not permitted to modify threads because it does not hold `https://developer.android.com/reference/java/lang/RuntimePermission``("modifyThread")` |

### shutdownNow

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public List<Runnable> 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://developer.android.com/reference/java/util/concurrent/ForkJoinPool#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).

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/Runnable>` | an empty list <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException` | if a security manager exists and the caller is not permitted to modify threads because it does not hold `https://developer.android.com/reference/java/lang/RuntimePermission``("modifyThread")` |

### submit

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ForkJoinTask<T> submit (Callable<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://developer.android.com/reference/java/util/concurrent/Executors` class includes a set of methods
that can convert some other common closure-like objects,
for example, `https://developer.android.com/reference/java/security/PrivilegedAction` to
`https://developer.android.com/reference/java/util/concurrent/Callable` form so they can be submitted.

<br />

| Parameters ||
|---|---|
| `task` | `Callable`: the task to submit <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T>` | a Future representing pending completion of the task <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the task is null |
| `https://developer.android.com/reference/java/util/concurrent/RejectedExecutionException` | if the task cannot be scheduled for execution |

### submit

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ForkJoinTask<T> submit (ForkJoinTask<T> task)
```

Submits a ForkJoinTask for execution.

<br />

##### Implementation Requirements:

- This method is equivalent to `https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#externalSubmit(java.util.concurrent.ForkJoinTask<T>)` when called from a thread that is not in this pool.

| Parameters ||
|---|---|
| `task` | `ForkJoinTask`: the task to submit <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T>` | the task <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the task is null |
| `https://developer.android.com/reference/java/util/concurrent/RejectedExecutionException` | if the task cannot be scheduled for execution |

### submit

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ForkJoinTask<?> submit (Runnable 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.

<br />

| Parameters ||
|---|---|
| `task` | `Runnable`: the task to submit <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<?>` | a Future representing pending completion of the task <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the task is null |
| `https://developer.android.com/reference/java/util/concurrent/RejectedExecutionException` | if the task cannot be scheduled for execution |

### submit

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ForkJoinTask<T> submit (Runnable 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.

<br />

| Parameters ||
|---|---|
| `task` | `Runnable`: the task to submit <br /> |
| `result` | `T`: the result to return <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<T>` | a Future representing pending completion of the task <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the task is null |
| `https://developer.android.com/reference/java/util/concurrent/RejectedExecutionException` | if the task cannot be scheduled for execution |

### toString

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string identifying this pool, as well as its state <br /> |

## Protected methods

### drainTasksTo

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected int drainTasksTo (Collection<? super ForkJoinTask<?>> 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.

<br />

| Parameters ||
|---|---|
| `c` | `Collection`: the collection to transfer elements into <br /> |

| Returns ||
|---|---|
| `int` | the number of elements transferred <br /> |

### newTaskFor

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected RunnableFuture<T> newTaskFor (Runnable runnable, 
                T value)
```

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

<br />

| Parameters ||
|---|---|
| `runnable` | `Runnable`: the runnable task being wrapped <br /> |
| `value` | `T`: the default value for the returned future <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/RunnableFuture<T>` | 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 <br /> |

### newTaskFor

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected RunnableFuture<T> newTaskFor (Callable<T> callable)
```

Returns a `RunnableFuture` for the given callable task.

<br />

| Parameters ||
|---|---|
| `callable` | `Callable`: the callable task being wrapped <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/RunnableFuture<T>` | 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 <br /> |

### pollSubmission

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected ForkJoinTask<?> 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.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ForkJoinTask<?>` | the next submission, or `null` if none <br /> |