V - Vpublic abstract class AbstractFuture<V> extends Object implements Future<V>
| 限定符 | 构造器和说明 |
|---|---|
protected |
AbstractFuture()
Constructor for use by subclasses.
|
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
static <T> T |
checkNotNull(T reference)
Ensures that an object reference passed as a parameter to the calling method is not null.
|
V |
get()
The default
AbstractFuture implementation throws InterruptedException if the current
thread is interrupted before or during the call, even if the value is already available. |
V |
get(long timeout,
TimeUnit unit)
The default
AbstractFuture implementation throws InterruptedException if the current
thread is interrupted before or during the call, even if the value is already available. |
protected void |
interruptTask()
Subclasses can override this method to implement interruption of the future's computation.
|
boolean |
isCancelled() |
boolean |
isDone() |
protected boolean |
set(V value)
Subclasses should invoke this method to set the result of the computation to
value. |
protected boolean |
setException(Throwable throwable)
Subclasses should invoke this method to set the result of the computation to an error,
throwable. |
protected boolean |
wasInterrupted()
Returns true if this future was cancelled with
mayInterruptIfRunning set to true. |
public V get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException, ExecutionException
The default AbstractFuture implementation throws InterruptedException if the current
thread is interrupted before or during the call, even if the value is already available.
get 在接口中 Future<V>InterruptedException - if the current thread was interrupted before or during the call (optional but recommended).CancellationExceptionTimeoutExceptionExecutionExceptionpublic V get() throws InterruptedException, ExecutionException
The default AbstractFuture implementation throws InterruptedException if the current
thread is interrupted before or during the call, even if the value is already available.
get 在接口中 Future<V>InterruptedException - if the current thread was interrupted before or during the call (optional but recommended).CancellationExceptionExecutionExceptionpublic boolean isCancelled()
isCancelled 在接口中 Future<V>protected void interruptTask()
cancel(true).
The default implementation does nothing.
protected final boolean wasInterrupted()
mayInterruptIfRunning set to true.protected boolean set(V value)
value. This will
set the state of the future to AbstractFuture.Sync.COMPLETED and invoke the listeners if the
state was successfully changed.value - the value that was the result of the task.protected boolean setException(Throwable throwable)
throwable. This will set the state of the future to AbstractFuture.Sync.COMPLETED and
invoke the listeners if the state was successfully changed.throwable - the exception that the task failed with.public static <T> T checkNotNull(T reference)
reference - an object referenceNullPointerException - if reference is nullCopyright © 2018. All rights reserved.