public class SettableFuture<T> extends Object implements Future<T>
Description:
| 构造器和说明 |
|---|
SettableFuture() |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
T |
get()
Retrieve the value.
|
T |
get(long timeout,
TimeUnit unit)
Retrieve the value.
|
protected void |
interruptTask()
Subclasses can override this method to implement interruption of the
future's computation.
|
boolean |
isCancelled() |
boolean |
isDone() |
boolean |
set(T value)
Set the value of this future.
|
boolean |
setException(Throwable exception)
Set the exception of this future.
|
public boolean set(T value)
true if the
value was set successfully, or false if the future has already
been set or cancelled.value - the value that will be set.true if the value was successfully set, else
false.public boolean setException(Throwable exception)
true if
the exception was set successfully, or false if the future has
already been set or cancelled.exception - the value that will be set.true if the exception was successfully set, else
false.public boolean isCancelled()
isCancelled 在接口中 Future<T>public T get() throws InterruptedException, ExecutionException
Will return the value if it has been set via set(Object), throw
an ExecutionException if it has been set via
setException(Throwable) or throw a
CancellationException if it has been
cancelled.
get 在接口中 Future<T>InterruptedExceptionExecutionExceptionpublic T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Will return the value if it has been set via set(Object), throw
an ExecutionException if it has been set via
setException(Throwable) or throw a
CancellationException if it has been
cancelled.
get 在接口中 Future<T>timeout - the maximum time to wait.unit - the time unit of the timeout argument.InterruptedExceptionExecutionExceptionTimeoutExceptionprotected void interruptTask()
cancel(true).
The default implementation does nothing.
Copyright © 2019. All rights reserved.