# Executors

public class **Executors** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
Factory and utility methods for `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executor.html`, `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html`, `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledExecutorService.html`, `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html`, and `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html` classes defined in this
package. This class supports the following kinds of methods:

- Methods that create and return an `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html` set up with commonly useful configuration settings.
- Methods that create and return a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledExecutorService.html` set up with commonly useful configuration settings.
- Methods that create and return a "wrapped" ExecutorService, that disables reconfiguration by making implementation-specific methods inaccessible.
- Methods that create and return a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html` that sets newly created threads to a known state.
- Methods that create and return a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html` out of other closure-like forms, so they can be used in execution methods requiring `Callable`.

<br />

### Public Method Summary

|---|---|
| static [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#callable(java.lang.Runnable))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) task) Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html` object that, when called, runs the given task and returns `null`. |
| static [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#callable(java.security.PrivilegedAction<?>))([PrivilegedAction](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedAction.html)\<?\> action) Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html` object that, when called, runs the given privileged action and returns its result. |
| static [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#callable(java.security.PrivilegedExceptionAction<?>))([PrivilegedExceptionAction](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedExceptionAction.html)\<?\> action) Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html` object that, when called, runs the given privileged exception action and returns its result. |
| static \<T\> [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\> | [callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#callable(java.lang.Runnable,%20T))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) task, T result) Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html` object that, when called, runs the given task and returns the given result. |
| static [ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) | [defaultThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#defaultThreadFactory())() Returns a default thread factory used to create new threads. |
| static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html) | [newCachedThreadPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#newCachedThreadPool())() Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available. |
| static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html) | [newCachedThreadPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#newCachedThreadPool(java.util.concurrent.ThreadFactory))([ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) threadFactory) Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available, and uses the provided ThreadFactory to create new threads when needed. |
| static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html) | [newFixedThreadPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#newFixedThreadPool(int,%20java.util.concurrent.ThreadFactory))(int nThreads, [ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) threadFactory) Creates a thread pool that reuses a fixed number of threads operating off a shared unbounded queue, using the provided ThreadFactory to create new threads when needed. |
| static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html) | [newFixedThreadPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#newFixedThreadPool(int))(int nThreads) Creates a thread pool that reuses a fixed number of threads operating off a shared unbounded queue. |
| static [ScheduledExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledExecutorService.html) | [newScheduledThreadPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#newScheduledThreadPool(int))(int corePoolSize) Creates a thread pool that can schedule commands to run after a given delay, or to execute periodically. |
| static [ScheduledExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledExecutorService.html) | [newScheduledThreadPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#newScheduledThreadPool(int,%20java.util.concurrent.ThreadFactory))(int corePoolSize, [ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) threadFactory) Creates a thread pool that can schedule commands to run after a given delay, or to execute periodically. |
| static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html) | [newSingleThreadExecutor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#newSingleThreadExecutor(java.util.concurrent.ThreadFactory))([ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) threadFactory) Creates an Executor that uses a single worker thread operating off an unbounded queue, and uses the provided ThreadFactory to create a new thread when needed. |
| static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html) | [newSingleThreadExecutor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#newSingleThreadExecutor())() Creates an Executor that uses a single worker thread operating off an unbounded queue. |
| static [ScheduledExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledExecutorService.html) | [newSingleThreadScheduledExecutor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#newSingleThreadScheduledExecutor())() Creates a single-threaded executor that can schedule commands to run after a given delay, or to execute periodically. |
| static [ScheduledExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledExecutorService.html) | [newSingleThreadScheduledExecutor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#newSingleThreadScheduledExecutor(java.util.concurrent.ThreadFactory))([ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) threadFactory) Creates a single-threaded executor that can schedule commands to run after a given delay, or to execute periodically. |
| static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html) | [newWorkStealingPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#newWorkStealingPool(int))(int parallelism) Creates a thread pool that maintains enough threads to support the given parallelism level, and may use multiple queues to reduce contention. |
| static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html) | [newWorkStealingPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#newWorkStealingPool())() Creates a work-stealing thread pool using the number of {@linkplain Runtime#availableProcessors available processors} as its target parallelism level. |
| static \<T\> [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\> | [privilegedCallable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#privilegedCallable(java.util.concurrent.Callable<T>))([Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\> callable) Legacy security code; do not use. |
| static \<T\> [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\> | [privilegedCallableUsingCurrentClassLoader](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#privilegedCallableUsingCurrentClassLoader(java.util.concurrent.Callable<T>))([Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\> callable) Legacy security code; do not use. |
| static [ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) | [privilegedThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#privilegedThreadFactory())() Legacy security code; do not use. |
| static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html) | [unconfigurableExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#unconfigurableExecutorService(java.util.concurrent.ExecutorService))([ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html) executor) Returns an object that delegates all defined `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html` methods to the given executor, but not any other methods that might otherwise be accessible using casts. |
| static [ScheduledExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledExecutorService.html) | [unconfigurableScheduledExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#unconfigurableScheduledExecutorService(java.util.concurrent.ScheduledExecutorService))([ScheduledExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledExecutorService.html) executor) Returns an object that delegates all defined `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledExecutorService.html` methods to the given executor, but not any other methods that might otherwise be accessible using casts. |

### Inherited Method Summary

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

## Public Methods

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

Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html` object that, when
called, runs the given task and returns `null`.

##### Parameters

| task | the task to run |
|---|---|

##### Returns

- a callable object

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if task null |
|---|---|

#### public static [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\>
**callable**
([PrivilegedAction](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedAction.html)\<?\> action)

Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html` object that, when
called, runs the given privileged action and returns its result.

##### Parameters

| action | the privileged action to run |
|---|---|

##### Returns

- a callable object

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if action null |
|---|---|

#### public static [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\>
**callable**
([PrivilegedExceptionAction](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedExceptionAction.html)\<?\> action)

Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html` object that, when
called, runs the given privileged exception action and returns
its result.

##### Parameters

| action | the privileged exception action to run |
|---|---|

##### Returns

- a callable object

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if action null |
|---|---|

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

Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html` object that, when
called, runs the given task and returns the given result. This
can be useful when applying methods requiring a
`Callable` to an otherwise resultless action.

##### Parameters

| task | the task to run |
| result | the result to return |
|---|---|

##### Returns

- a callable object

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if task null |
|---|---|

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

Returns a default thread factory used to create new threads.
This factory creates all new threads used by an Executor in the
same `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ThreadGroup.html`. Each new
thread is created as a non-daemon thread with priority set to
the smaller of `Thread.NORM_PRIORITY` and the maximum
priority permitted in the thread group. New threads have names
accessible via `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Thread.html#getName()` of
*pool-N-thread-M* , where *N* is the sequence
number of this factory, and *M* is the sequence number
of the thread created by this factory.

##### Returns

- a thread factory

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

Creates a thread pool that creates new threads as needed, but
will reuse previously constructed threads when they are
available. These pools will typically improve the performance
of programs that execute many short-lived asynchronous tasks.
Calls to `execute` will reuse previously constructed
threads if available. If no existing thread is available, a new
thread will be created and added to the pool. Threads that have
not been used for sixty seconds are terminated and removed from
the cache. Thus, a pool that remains idle for long enough will
not consume any resources. Note that pools with similar
properties but different details (for example, timeout parameters)
may be created using `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.html` constructors.

##### Returns

- the newly created thread pool

#### public static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html)
**newCachedThreadPool**
([ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) threadFactory)

Creates a thread pool that creates new threads as needed, but
will reuse previously constructed threads when they are
available, and uses the provided
ThreadFactory to create new threads when needed.

##### Parameters

| threadFactory | the factory to use when creating new threads |
|---|---|

##### Returns

- the newly created thread pool

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if threadFactory is null |
|---|---|

#### public static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html)
**newFixedThreadPool**
(int nThreads, [ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) threadFactory)

Creates a thread pool that reuses a fixed number of threads
operating off a shared unbounded queue, using the provided
ThreadFactory to create new threads when needed. At any point,
at most `nThreads` threads will be active processing
tasks. If additional tasks are submitted when all threads are
active, they will wait in the queue until a thread is
available. If any thread terminates due to a failure during
execution prior to shutdown, a new one will take its place if
needed to execute subsequent tasks. The threads in the pool will
exist until it is explicitly `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#shutdown()`.

##### Parameters

| nThreads | the number of threads in the pool |
| threadFactory | the factory to use when creating new threads |
|---|---|

##### Returns

- the newly created thread pool

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if threadFactory is null |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if `nThreads <= 0` |
|---|---|

#### public static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html)
**newFixedThreadPool**
(int nThreads)

Creates a thread pool that reuses a fixed number of threads
operating off a shared unbounded queue. At any point, at most
`nThreads` threads will be active processing tasks.
If additional tasks are submitted when all threads are active,
they will wait in the queue until a thread is available.
If any thread terminates due to a failure during execution
prior to shutdown, a new one will take its place if needed to
execute subsequent tasks. The threads in the pool will exist
until it is explicitly `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html#shutdown()`.

##### Parameters

| nThreads | the number of threads in the pool |
|---|---|

##### Returns

- the newly created thread pool

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if `nThreads <= 0` |
|---|---|

#### public static [ScheduledExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledExecutorService.html)
**newScheduledThreadPool**
(int corePoolSize)

Creates a thread pool that can schedule commands to run after a
given delay, or to execute periodically.

##### Parameters

| corePoolSize | the number of threads to keep in the pool, even if they are idle |
|---|---|

##### Returns

- a newly created scheduled thread pool

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if `corePoolSize < 0` |
|---|---|

#### public static [ScheduledExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledExecutorService.html)
**newScheduledThreadPool**
(int corePoolSize, [ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) threadFactory)

Creates a thread pool that can schedule commands to run after a
given delay, or to execute periodically.

##### Parameters

| corePoolSize | the number of threads to keep in the pool, even if they are idle |
| threadFactory | the factory to use when the executor creates a new thread |
|---|---|

##### Returns

- a newly created scheduled thread pool

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if `corePoolSize < 0` |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if threadFactory is null |
|---|---|

#### public static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html)
**newSingleThreadExecutor**
([ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) threadFactory)

Creates an Executor that uses a single worker thread operating
off an unbounded queue, and uses the provided ThreadFactory to
create a new thread when needed. Unlike the otherwise
equivalent `newFixedThreadPool(1, threadFactory)` the
returned executor is guaranteed not to be reconfigurable to use
additional threads.

##### Parameters

| threadFactory | the factory to use when creating new threads |
|---|---|

##### Returns

- the newly created single-threaded Executor

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if threadFactory is null |
|---|---|

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

Creates an Executor that uses a single worker thread operating
off an unbounded queue. (Note however that if this single
thread terminates due to a failure during execution prior to
shutdown, a new one will take its place if needed to execute
subsequent tasks.) Tasks are guaranteed to execute
sequentially, and no more than one task will be active at any
given time. Unlike the otherwise equivalent
`newFixedThreadPool(1)` the returned executor is
guaranteed not to be reconfigurable to use additional threads.

##### Returns

- the newly created single-threaded Executor

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

Creates a single-threaded executor that can schedule commands
to run after a given delay, or to execute periodically.
(Note however that if this single
thread terminates due to a failure during execution prior to
shutdown, a new one will take its place if needed to execute
subsequent tasks.) Tasks are guaranteed to execute
sequentially, and no more than one task will be active at any
given time. Unlike the otherwise equivalent
`newScheduledThreadPool(1)` the returned executor is
guaranteed not to be reconfigurable to use additional threads.

##### Returns

- the newly created scheduled executor

#### public static [ScheduledExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledExecutorService.html)
**newSingleThreadScheduledExecutor**
([ThreadFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadFactory.html) threadFactory)

Creates a single-threaded executor that can schedule commands
to run after a given delay, or to execute periodically. (Note
however that if this single thread terminates due to a failure
during execution prior to shutdown, a new one will take its
place if needed to execute subsequent tasks.) Tasks are
guaranteed to execute sequentially, and no more than one task
will be active at any given time. Unlike the otherwise
equivalent `newScheduledThreadPool(1, threadFactory)`
the returned executor is guaranteed not to be reconfigurable to
use additional threads.

##### Parameters

| threadFactory | the factory to use when creating new threads |
|---|---|

##### Returns

- a newly created scheduled executor

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if threadFactory is null |
|---|---|

#### public static [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html)
**newWorkStealingPool**
(int parallelism)

Creates a thread pool that maintains enough threads to support
the given parallelism level, and may use multiple queues to
reduce contention. The parallelism level corresponds to the
maximum number of threads actively engaged in, or available to
engage in, task processing. The actual number of threads may
grow and shrink dynamically. A work-stealing pool makes no
guarantees about the order in which submitted tasks are
executed.

##### Parameters

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

##### Returns

- the newly created thread pool

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if `parallelism <= 0` |
|---|---|

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

Creates a work-stealing thread pool using the number of
{@linkplain Runtime#availableProcessors available processors}
as its target parallelism level.

##### Returns

- the newly created thread pool

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html#newWorkStealingPool(int)`

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

Legacy security code; do not use.

##### Parameters

| callable |   |
|---|---|

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

Legacy security code; do not use.

##### Parameters

| callable |   |
|---|---|

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

Legacy security code; do not use.

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

Returns an object that delegates all defined `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html` methods to the given executor, but not any
other methods that might otherwise be accessible using
casts. This provides a way to safely "freeze" configuration and
disallow tuning of a given concrete implementation.

##### Parameters

| executor | the underlying implementation |
|---|---|

##### Returns

- an `ExecutorService` instance

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if executor null |
|---|---|

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

Returns an object that delegates all defined `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledExecutorService.html` methods to the given executor, but
not any other methods that might otherwise be accessible using
casts. This provides a way to safely "freeze" configuration and
disallow tuning of a given concrete implementation.

##### Parameters

| executor | the underlying implementation |
|---|---|

##### Returns

- a `ScheduledExecutorService` instance

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if executor null |
|---|---|