# AbstractExecutorService

public abstract class **AbstractExecutorService** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
implements [ExecutorService](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html)

|---|---|---|
| Known Direct Subclasses [ForkJoinPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html), [ThreadPoolExecutor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.html) |---|---| | [ForkJoinPool](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinPool.html) | An `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html` for running `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ForkJoinTask.html`s. | | [ThreadPoolExecutor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.html) | An `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html` that executes each submitted task using one of possibly several pooled threads, normally configured using `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Executors.html` factory methods. | |||

|---|---|---|
| Known Indirect Subclasses [ScheduledThreadPoolExecutor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledThreadPoolExecutor.html) |---|---| | [ScheduledThreadPoolExecutor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ScheduledThreadPoolExecutor.html) | A `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.html` that can additionally schedule commands to run after a given delay, or to execute periodically. | |||

Provides default implementations of `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ExecutorService.html`
execution methods. This class implements the `submit`,
`invokeAny` and `invokeAll` methods using a
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RunnableFuture.html` returned by `newTaskFor`, which defaults
to the `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/FutureTask.html` class provided in this package. For example,
the implementation of `submit(Runnable)` creates an
associated `RunnableFuture` that is executed and
returned. Subclasses may override the `newTaskFor` methods
to return `RunnableFuture` implementations other than
`FutureTask`.

**Extension example** . Here is a sketch of a class
that customizes `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.html` to use
a `CustomTask` class instead of the default `FutureTask`:

     public class CustomThreadPoolExecutor extends ThreadPoolExecutor {

       static class CustomTask<V> implements RunnableFuture<V> {...}

       protected <V> RunnableFuture<V> newTaskFor(Callable<V> c) {
           return new CustomTask<V>(c);
       }
       protected <V> RunnableFuture<V> newTaskFor(Runnable r, V v) {
           return new CustomTask<V>(r, v);
       }
       // ... add constructors, etc.
     }

<br />

### Public Constructor Summary

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

### Public Method Summary

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

### Protected Method Summary

|---|---|
| \<T\> [RunnableFuture](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RunnableFuture.html)\<T\> | [newTaskFor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/AbstractExecutorService.html#newTaskFor(java.lang.Runnable,%20T))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) runnable, T value) Returns a `RunnableFuture` for the given runnable and default value. |
| \<T\> [RunnableFuture](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RunnableFuture.html)\<T\> | [newTaskFor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/AbstractExecutorService.html#newTaskFor(java.util.concurrent.Callable<T>))([Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\> callable) Returns a `RunnableFuture` for the given callable task. |

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

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

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

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

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

## Public Constructors

#### public
**AbstractExecutorService**
()

<br />

## Public Methods

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

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

##### Parameters

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

##### Returns

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

##### Throws

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

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

Executes the given tasks, returning a list of Futures holding
their status and results
when all complete or the timeout expires, whichever happens first.
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Future.html#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.

##### Parameters

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

##### Returns

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

##### Throws

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

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

Executes the given tasks, returning the result
of one that has completed successfully (i.e., without throwing
an exception), if any do. 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.

##### Parameters

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

##### Returns

- the result returned by one of the tasks

##### Throws

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

#### public T
**invokeAny**
([Collection](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Collection.html)\<? extends [Callable](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/Callable.html)\<T\>\> tasks, long timeout, [TimeUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/TimeUnit.html) unit)

Executes the given tasks, returning the result
of one that has completed successfully (i.e., without throwing
an exception), if any do before the given timeout elapses.
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.

##### Parameters

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

##### Returns

- the result returned by one of the tasks

##### Throws

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

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

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


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

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

##### Parameters

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

##### Returns

- a Future representing pending completion of the task

##### Throws

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

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

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

##### Parameters

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

##### Returns

- a Future representing pending completion of the task

##### Throws

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

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

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

##### Parameters

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

##### Returns

- a Future representing pending completion of the task

##### Throws

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

## Protected Methods

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

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

##### Parameters

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

##### Returns

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

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

Returns a `RunnableFuture` for the given callable task.

##### Parameters

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

##### Returns

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