Package com.google.android.exoplayer2.util

## Class RunnableFutureTask<R,​E extends Exception>

- java.lang.Object
- - com.google.android.exoplayer2.util.RunnableFutureTask<R,​E>

- Type Parameters:
    `R` - The type of the result.
    `E` - The type of any `ExecutionException` cause.
  All Implemented Interfaces:
    `Runnable`, `Future<R>`, `RunnableFuture<R>`

      public abstract class RunnableFutureTask<R,​E extends Exception>
      extends Object
      implements RunnableFuture<R>

  A `RunnableFuture` that supports additional uninterruptible operations to query whether execution has started and finished.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `RunnableFutureTask()` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `blockUntilFinished()` | Blocks until the task has finished, or has been canceled without having been started.
    `void` | `blockUntilStarted()` | Blocks until the task has started, or has been canceled without having been started.
    `boolean` | `cancel​(boolean interruptIfRunning)` |
    `protected void` | `cancelWork()` | Cancels any work being done by `doWork()`.
    `protected abstract R` | `doWork()` | Performs the work or computation.
    `R` | `get()` |
    `R` | `get​(long timeout, TimeUnit unit)` |
    `boolean` | `isCancelled()` |
    `boolean` | `isDone()` |
    `void` | `run()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RunnableFutureTask

          protected RunnableFutureTask()

  - ### Method Detail

    - #### blockUntilStarted

          public final void blockUntilStarted()

      Blocks until the task has started, or has been canceled without having been started.

    - #### blockUntilFinished

          public final void blockUntilFinished()

      Blocks until the task has finished, or has been canceled without having been started.

    - #### get

          public final R get()
                      throws ExecutionException,
                             InterruptedException

      Specified by:
        `get` in interface `Future<R>`
      Throws:
        `ExecutionException`
        `InterruptedException`

    - #### get

          public final R get​(long timeout,
                             TimeUnit unit)
                      throws ExecutionException,
                             InterruptedException,
                             TimeoutException

      Specified by:
        `get` in interface `Future<R>`
      Throws:
        `ExecutionException`
        `InterruptedException`
        `TimeoutException`

    - #### cancel

          public final boolean cancel​(boolean interruptIfRunning)

      Specified by:
        `cancel` in interface `Future<R>`

    - #### isDone

          public final boolean isDone()

      Specified by:
        `isDone` in interface `Future<R>`

    - #### isCancelled

          public final boolean isCancelled()

      Specified by:
        `isCancelled` in interface `Future<R>`

    - #### run

          public final void run()

      Specified by:
        `run` in interface `Runnable`
      Specified by:
        `run` in interface `RunnableFuture<R>`

    - #### doWork

          protected abstract R doWork()
                               throws E extends Exception

      Performs the work or computation.
      Returns:
        The computed result.
      Throws:
        `E` - If an error occurred.
        `E extends Exception`

    - #### cancelWork

          protected void cancelWork()

      Cancels any work being done by `doWork()`. If `doWork()` is currently executing then the thread on which it's executing may be interrupted immediately after this method returns.

      The default implementation does nothing.