| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel(boolean mayInterruptIfRunning)
Attempts to cancel this execution.
|
T |
get()
Waits if necessary for the execution to complete, and then returns its result.
|
T |
get(long timeout,
TimeUnit unit)
Waits if necessary for at most the given time for the execution to complete, and then returns its result, if
available.
|
boolean |
isCancelled()
Returns
true if this execution was cancelled before it completed normally. |
boolean |
isDone()
Returns
true if this execution completed. |
public boolean cancel(boolean mayInterruptIfRunning)
cancel is called, this execution should never run. If the execution has already started, then the
mayInterruptIfRunning parameter determines whether the thread executing this task should be interrupted in
an attempt to stop the execution.
After this method returns, subsequent calls to isDone() will always return true. Subsequent calls to
isCancelled() will always return true if this method returned true.
cancel in interface Future<T>mayInterruptIfRunning - true if the thread executing this execution should be interrupted; otherwise,
in-progress executions are allowed to completefalse if the execution could not be cancelled, typically because it has already completed normally;
true otherwisepublic T get() throws InterruptedException, ExecutionException
get in interface Future<T>CancellationException - if the execution was cancelledExecutionException - if the execution threw an exceptionInterruptedException - if the current thread was interrupted while waitingpublic T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get in interface Future<T>timeout - the maximum time to waitunit - the time unit of the timeout argumentCancellationException - if the execution was cancelledExecutionException - if the execution threw an exceptionInterruptedException - if the current thread was interrupted while waitingTimeoutException - if the wait timed outNullPointerException - if unit is nullIllegalArgumentException - if timeout is < 0public boolean isCancelled()
true if this execution was cancelled before it completed normally.isCancelled in interface Future<T>true if this execution was cancelled before it completedCopyright © 2017. All Rights Reserved.