RunnableFutureTask


@UnstableApi
public abstract class RunnableFutureTask<R, E extends Exception> implements RunnableFuture


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

Parameters
<R>

The type of the result.

<E extends Exception>

The type of any ExecutionException cause.

Summary

Protected constructors

Public methods

final void

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

final void

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

final boolean
cancel(boolean interruptIfRunning)
final R
final R
@UnknownNull
get(long timeout, TimeUnit unit)
final boolean
final boolean
final void
run()

Protected methods

void

Cancels any work being done by doWork.

abstract R

Performs the work or computation.

Protected constructors

RunnableFutureTask

protected RunnableFutureTask()

Public methods

blockUntilFinished

public final void blockUntilFinished()

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

blockUntilStarted

public final void blockUntilStarted()

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

cancel

public final boolean cancel(boolean interruptIfRunning)

isCancelled

public final boolean isCancelled()

isDone

public final boolean isDone()

run

public final void run()

Protected methods

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.

doWork

@UnknownNull
protected abstract R doWork()

Performs the work or computation.

Returns
R

The computed result.

Throws
E

If an error occurred.