# RecursiveTask

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

# RecursiveTask

`
public


abstract
class
RecursiveTask
`  
`


``

extends `[ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)`<V>


``


`

|---|---|-----------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [java.util.concurrent.ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)\<V\> ||
|   | ↳ | java.util.concurrent.RecursiveTask\<V\> |

<br />

*** ** * ** ***

A recursive result-bearing[ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask).

For example, here is a task-based program for computing Factorials:  

     import java.util.concurrent.RecursiveTask;
     import java.math.BigInteger;
     public class Factorial {
       static class FactorialTask extends RecursiveTask<BigInteger> {
         private final int from, to;
         FactorialTask(int from, int to) { this.from = from; this.to = to; }
         protected BigInteger compute() {
           int range = to - from;
           if (range == 0) {                       // base case
             return BigInteger.valueOf(from);
           } else if (range == 1) {                // too small to parallelize
             return BigInteger.valueOf(from).multiply(BigInteger.valueOf(to));
           } else {                                // split in half
             int mid = from + range / 2;
             FactorialTask leftTask = new FactorialTask(from, mid);
             leftTask.fork();         // perform about half the work locally
             return new FactorialTask(mid + 1, to).compute()
                    .multiply(leftTask.join());
           }
         }
       }
       static BigInteger factorial(int n) { // uses ForkJoinPool.commonPool()
         return (n <= 1) ? BigInteger.ONE : new FactorialTask(1, n).invoke();
       }
       public static void main(String[] args) {
         System.out.println(factorial(Integer.parseInt(args[0])));
       }
     }

<br />

## Summary

|                                                                  ### Public constructors                                                                   ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[RecursiveTask](https://developer.android.com/reference/java/util/concurrent/RecursiveTask#RecursiveTask())`() ` Constructor for subclasses to call. |

|                                                                                                                                                                           ### Public methods                                                                                                                                                                            ||
|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` final V` | ` `[getRawResult](https://developer.android.com/reference/java/util/concurrent/RecursiveTask#getRawResult())`() ` Returns the result that would be returned by[join()](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#join()), even if this task completed abnormally, or`null`if this task is not known to have been completed. |

|                                                                                     ### Protected methods                                                                                      ||
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract V`    | ` `[compute](https://developer.android.com/reference/java/util/concurrent/RecursiveTask#compute())`() ` The main computation performed by this task.                         |
| ` final boolean` | ` `[exec](https://developer.android.com/reference/java/util/concurrent/RecursiveTask#exec())`() ` Implements execution conventions for RecursiveTask.                        |
| ` final void`    | ` `[setRawResult](https://developer.android.com/reference/java/util/concurrent/RecursiveTask#setRawResult(V))`(V value) ` Forces the given value to be returned as a result. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.util.concurrent.ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)` ` |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` static <T> `[ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)`<T>`                                                                                         | ` `[adapt](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#adapt(java.lang.Runnable,%20T))`(`[Runnable](https://developer.android.com/reference/java/lang/Runnable)` runnable, T result) ` Returns a new`ForkJoinTask`that performs the`run`method of the given`Runnable`as its action, and returns the given result upon[join()](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#join()).                                                                                                                                  | | ` static `[ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)`<?>`                                                                                             | ` `[adapt](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#adapt(java.lang.Runnable))`(`[Runnable](https://developer.android.com/reference/java/lang/Runnable)` runnable) ` Returns a new`ForkJoinTask`that performs the`run`method of the given`Runnable`as its action, and returns a null result upon[join()](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#join()).                                                                                                                                                    | | ` static <T> `[ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)`<T>`                                                                                         | ` `[adapt](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#adapt(java.util.concurrent.Callable<?%20extends%20T>))`(`[Callable](https://developer.android.com/reference/java/util/concurrent/Callable)`<? extends T> callable) ` Returns a new`ForkJoinTask`that performs the`call`method of the given`Callable`as its action, and returns its result upon[join()](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#join()), translating any checked exceptions encountered into`RuntimeException`.                           | | ` static <T> `[ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)`<T>`                                                                                         | ` `[adaptInterruptible](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#adaptInterruptible(java.util.concurrent.Callable<?%20extends%20T>))`(`[Callable](https://developer.android.com/reference/java/util/concurrent/Callable)`<? extends T> callable) ` Returns a new`ForkJoinTask`that performs the`call`method of the given`Callable`as its action, and returns its result upon[join()](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#join()), translating any checked exceptions encountered into`RuntimeException`. | | ` boolean`                                                                                                                                                                                           | ` `[cancel](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#cancel(boolean))`(boolean mayInterruptIfRunning) ` Attempts to cancel execution of this task.                                                                                                                                                                                                                                                                                                                                                                                             | | ` final boolean`                                                                                                                                                                                     | ` `[compareAndSetForkJoinTaskTag](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#compareAndSetForkJoinTaskTag(short,%20short))`(short expect, short update) ` Atomically conditionally sets the tag value for this task.                                                                                                                                                                                                                                                                                                                             | | ` void`                                                                                                                                                                                              | ` `[complete](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#complete(V))`(V value) ` Completes this task, and if not already aborted or cancelled, returning the given value as the result of subsequent invocations of`join`and related operations.                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                                                                                                              | ` `[completeExceptionally](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#completeExceptionally(java.lang.Throwable))`(`[Throwable](https://developer.android.com/reference/java/lang/Throwable)` ex) ` Completes this task abnormally, and if not already aborted or cancelled, causes it to throw the given exception upon`join`and related operations.                                                                                                                                                                                            | | ` `[Throwable](https://developer.android.com/reference/java/lang/Throwable)                                                                                                                          | ` `[exceptionNow](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#exceptionNow())`() ` Returns the exception thrown by the task, without waiting.                                                                                                                                                                                                                                                                                                                                                                                                     | | ` abstract boolean`                                                                                                                                                                                  | ` `[exec](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#exec())`() ` Immediately performs the base action of this task and returns true if, upon return from this method, this task is guaranteed to have completed.                                                                                                                                                                                                                                                                                                                                | | ` final `[ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)`<V>`                                                                                              | ` `[fork](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#fork())`() ` Arranges to asynchronously execute this task in the pool the current task is running in, if applicable, or using the[ForkJoinPool.commonPool()](https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#commonPool())if not[inForkJoinPool()](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#inForkJoinPool()).                                                                                                                   | | ` final V`                                                                                                                                                                                           | ` `[get](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#get(long,%20java.util.concurrent.TimeUnit))`(long timeout, `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit)` unit) ` Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.                                                                                                                                                                                                           | | ` final V`                                                                                                                                                                                           | ` `[get](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#get())`() ` Waits if necessary for the computation to complete, and then retrieves its result.                                                                                                                                                                                                                                                                                                                                                                                               | | ` final `[Throwable](https://developer.android.com/reference/java/lang/Throwable)                                                                                                                    | ` `[getException](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#getException())`() ` Returns the exception thrown by the base computation, or a`CancellationException`if cancelled, or`null`if none or if the method has not yet completed.                                                                                                                                                                                                                                                                                                         | | ` final short`                                                                                                                                                                                       | ` `[getForkJoinTaskTag](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#getForkJoinTaskTag())`() ` Returns the tag for this task.                                                                                                                                                                                                                                                                                                                                                                                                                     | | ` static `[ForkJoinPool](https://developer.android.com/reference/java/util/concurrent/ForkJoinPool)                                                                                                  | ` `[getPool](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#getPool())`() ` Returns the pool hosting the current thread, or`null`if the current thread is executing outside of any ForkJoinPool.                                                                                                                                                                                                                                                                                                                                                     | | ` static int`                                                                                                                                                                                        | ` `[getQueuedTaskCount](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#getQueuedTaskCount())`() ` Returns an estimate of the number of tasks that have been forked by the current worker thread but not yet executed.                                                                                                                                                                                                                                                                                                                                | | ` abstract V`                                                                                                                                                                                        | ` `[getRawResult](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#getRawResult())`() ` Returns the result that would be returned by[join()](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#join()), even if this task completed abnormally, or`null`if this task is not known to have been completed.                                                                                                                                                                                                                      | | ` static int`                                                                                                                                                                                        | ` `[getSurplusQueuedTaskCount](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#getSurplusQueuedTaskCount())`() ` Returns an estimate of how many more locally queued tasks are held by the current worker thread than there are other worker threads that might steal them, or zero if this thread is not operating in a ForkJoinPool.                                                                                                                                                                                                                | | ` static void`                                                                                                                                                                                       | ` `[helpQuiesce](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#helpQuiesce())`() ` Possibly executes tasks until the pool hosting the current task[is quiescent](https://developer.android.com/reference/java/util/concurrent/ForkJoinPool#isQuiescent()).                                                                                                                                                                                                                                                                                          | | ` static boolean`                                                                                                                                                                                    | ` `[inForkJoinPool](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#inForkJoinPool())`() ` Returns`true`if the current thread is a[ForkJoinWorkerThread](https://developer.android.com/reference/java/util/concurrent/ForkJoinWorkerThread)executing as a ForkJoinPool computation.                                                                                                                                                                                                                                                                   | | ` final V`                                                                                                                                                                                           | ` `[invoke](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#invoke())`() ` Commences performing this task, awaits its completion if necessary, and returns its result, or throws an (unchecked)`RuntimeException`or`Error`if the underlying computation did so.                                                                                                                                                                                                                                                                                       | | ` static void`                                                                                                                                                                                       | ` `[invokeAll](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#invokeAll(java.util.concurrent.ForkJoinTask<?>,%20java.util.concurrent.ForkJoinTask<?>))`(`[ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)`<?> t1, `[ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)`<?> t2) ` Forks the given tasks, returning when`isDone`holds for each task or an (unchecked) exception is encountered, in which case the exception is rethrown.                                | | ` static <T extends `[ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)`<?>> `[Collection](https://developer.android.com/reference/java/util/Collection)`<T>` | ` `[invokeAll](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#invokeAll(java.util.Collection<T>))`(`[Collection](https://developer.android.com/reference/java/util/Collection)`<T> tasks) ` Forks all tasks in the specified collection, returning when`isDone`holds for each task or an (unchecked) exception is encountered, in which case the exception is rethrown.                                                                                                                                                                              | | ` static void`                                                                                                                                                                                       | ` `[invokeAll](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#invokeAll(java.util.concurrent.ForkJoinTask<?>[]))`(`[ForkJoinTask...](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)`<?> tasks) ` Forks the given tasks, returning when`isDone`holds for each task or an (unchecked) exception is encountered, in which case the exception is rethrown.                                                                                                                                                                   | | ` final boolean`                                                                                                                                                                                     | ` `[isCancelled](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#isCancelled())`() ` Returns`true`if this task was cancelled before it completed normally.                                                                                                                                                                                                                                                                                                                                                                                            | | ` final boolean`                                                                                                                                                                                     | ` `[isCompletedAbnormally](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#isCompletedAbnormally())`() ` Returns`true`if this task threw an exception or was cancelled.                                                                                                                                                                                                                                                                                                                                                                               | | ` final boolean`                                                                                                                                                                                     | ` `[isCompletedNormally](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#isCompletedNormally())`() ` Returns`true`if this task completed without throwing an exception and was not cancelled.                                                                                                                                                                                                                                                                                                                                                         | | ` final boolean`                                                                                                                                                                                     | ` `[isDone](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#isDone())`() ` Returns`true`if this task completed.                                                                                                                                                                                                                                                                                                                                                                                                                                       | | ` final V`                                                                                                                                                                                           | ` `[join](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#join())`() ` Returns the result of the computation when it[is done](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#isDone()).                                                                                                                                                                                                                                                                                                                                    | | ` static `[ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)`<?>`                                                                                             | ` `[peekNextLocalTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#peekNextLocalTask())`() ` Returns, but does not unschedule or execute, a task queued by the current thread but not yet executed, if one is immediately available.                                                                                                                                                                                                                                                                                                              | | ` static `[ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)`<?>`                                                                                             | ` `[pollNextLocalTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#pollNextLocalTask())`() ` Unschedules and returns, without executing, the next task queued by the current thread but not yet executed, if the current thread is operating in a ForkJoinPool.                                                                                                                                                                                                                                                                                   | | ` static `[ForkJoinTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask)`<?>`                                                                                             | ` `[pollTask](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#pollTask())`() ` If the current thread is operating in a ForkJoinPool, unschedules and returns, without executing, the next task queued by the current thread but not yet executed, if one is available, or if not available, a task that was forked by some other thread, if available.                                                                                                                                                                                                | | ` final void`                                                                                                                                                                                        | ` `[quietlyComplete](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#quietlyComplete())`() ` Completes this task normally without setting a value.                                                                                                                                                                                                                                                                                                                                                                                                    | | ` final void`                                                                                                                                                                                        | ` `[quietlyInvoke](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#quietlyInvoke())`() ` Commences performing this task and awaits its completion if necessary, without returning its result or throwing its exception.                                                                                                                                                                                                                                                                                                                               | | ` final boolean`                                                                                                                                                                                     | ` `[quietlyJoin](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#quietlyJoin(long,%20java.util.concurrent.TimeUnit))`(long timeout, `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit)` unit) ` Tries to join this task, returning true if it completed (possibly exceptionally) before the given timeout and the current thread has not been interrupted.                                                                                                                                                            | | ` final void`                                                                                                                                                                                        | ` `[quietlyJoin](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#quietlyJoin())`() ` Joins this task, without returning its result or throwing its exception.                                                                                                                                                                                                                                                                                                                                                                                         | | ` final boolean`                                                                                                                                                                                     | ` `[quietlyJoinUninterruptibly](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#quietlyJoinUninterruptibly(long,%20java.util.concurrent.TimeUnit))`(long timeout, `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit)` unit) ` Tries to join this task, returning true if it completed (possibly exceptionally) before the given timeout.                                                                                                                                                                              | | ` void`                                                                                                                                                                                              | ` `[reinitialize](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#reinitialize())`() ` Resets the internal bookkeeping state of this task, allowing a subsequent`fork`.                                                                                                                                                                                                                                                                                                                                                                               | | ` V`                                                                                                                                                                                                 | ` `[resultNow](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#resultNow())`() ` Returns the computed result, without waiting.                                                                                                                                                                                                                                                                                                                                                                                                                        | | ` final short`                                                                                                                                                                                       | ` `[setForkJoinTaskTag](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#setForkJoinTaskTag(short))`(short newValue) ` Atomically sets the tag value for this task and returns the old value.                                                                                                                                                                                                                                                                                                                                                          | | ` abstract void`                                                                                                                                                                                     | ` `[setRawResult](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#setRawResult(V))`(V value) ` Forces the given value to be returned as a result.                                                                                                                                                                                                                                                                                                                                                                                                     | | ` `[Future.State](https://developer.android.com/reference/java/util/concurrent/Future.State)                                                                                                         | ` `[state](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#state())`() ` <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | | ` boolean`                                                                                                                                                                                           | ` `[tryUnfork](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#tryUnfork())`() ` Tries to unschedule this task for execution.                                                                                                                                                                                                                                                                                                                                                                                                                         | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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` `[java.util.concurrent.Future](https://developer.android.com/reference/java/util/concurrent/Future)` ` |------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean`                                                                                  | ` `[cancel](https://developer.android.com/reference/java/util/concurrent/Future#cancel(boolean))`(boolean mayInterruptIfRunning) ` Attempts to cancel execution of this task.                                                                                                                                                                                   | | ` default `[Throwable](https://developer.android.com/reference/java/lang/Throwable)                  | ` `[exceptionNow](https://developer.android.com/reference/java/util/concurrent/Future#exceptionNow())`() ` Returns the exception thrown by the task, without waiting.                                                                                                                                                                                           | | ` abstract V`                                                                                        | ` `[get](https://developer.android.com/reference/java/util/concurrent/Future#get(long,%20java.util.concurrent.TimeUnit))`(long timeout, `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit)` unit) ` Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available. | | ` abstract V`                                                                                        | ` `[get](https://developer.android.com/reference/java/util/concurrent/Future#get())`() ` Waits if necessary for the computation to complete, and then retrieves its result.                                                                                                                                                                                     | | ` abstract boolean`                                                                                  | ` `[isCancelled](https://developer.android.com/reference/java/util/concurrent/Future#isCancelled())`() ` Returns`true`if this task was cancelled before it completed normally.                                                                                                                                                                                  | | ` abstract boolean`                                                                                  | ` `[isDone](https://developer.android.com/reference/java/util/concurrent/Future#isDone())`() ` Returns`true`if this task completed.                                                                                                                                                                                                                             | | ` default V`                                                                                         | ` `[resultNow](https://developer.android.com/reference/java/util/concurrent/Future#resultNow())`() ` Returns the computed result, without waiting.                                                                                                                                                                                                              | | ` default `[Future.State](https://developer.android.com/reference/java/util/concurrent/Future.State) | ` `[state](https://developer.android.com/reference/java/util/concurrent/Future#state())`() ` <br />                                                                                                                                                                                                                                                             | ||

## Public constructors

### RecursiveTask

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

```
public RecursiveTask ()
```

Constructor for subclasses to call.

<br />

## Public methods

### getRawResult

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

```
public final V getRawResult ()
```

Returns the result that would be returned by[join()](https://developer.android.com/reference/java/util/concurrent/ForkJoinTask#join()), even if this task completed abnormally, or`null`if this task is not known to have been completed. This method is designed to aid debugging, as well as to support extensions. Its use in any other context is discouraged.

<br />

|                     Returns                      ||
|-----|---------------------------------------------|
| `V` | the result, or`null`if not completed <br /> |

## Protected methods

### compute

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

```
protected abstract V compute ()
```

The main computation performed by this task.

<br />

|                  Returns                  ||
|-----|--------------------------------------|
| `V` | the result of the computation <br /> |

### exec

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

```
protected final boolean exec ()
```

Implements execution conventions for RecursiveTask.

<br />

|                                 Returns                                  ||
|-----------|---------------------------------------------------------------|
| `boolean` | `true`if this task is known to have completed normally <br /> |

### setRawResult

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

```
protected final void setRawResult (V value)
```

Forces the given value to be returned as a result. This method is designed to support extensions, and should not in general be called otherwise.

<br />

|           Parameters           ||
|---------|-----------------------|
| `value` | `V`: the value <br /> |