public interface Future<V>
extends java.util.concurrent.Future<V>
| 限定符和类型 | 方法和说明 |
|---|---|
Future<V> |
addListener(GenericFutureListener<? extends Future<? super V>> listener)
Adds the specified listener to this future.
|
Future<V> |
addListeners(GenericFutureListener<? extends Future<? super V>>... listeners)
Adds the specified listeners to this future.
|
Future<V> |
await()
Waits for this future to be completed.
|
boolean |
await(long timeoutMillis)
Waits for this future to be completed within the
specified time limit.
|
boolean |
await(long timeout,
java.util.concurrent.TimeUnit unit)
Waits for this future to be completed within the
specified time limit.
|
Future<V> |
awaitUninterruptibly()
Waits for this future to be completed without
interruption.
|
boolean |
awaitUninterruptibly(long timeoutMillis)
Waits for this future to be completed within the
specified time limit without interruption.
|
boolean |
awaitUninterruptibly(long timeout,
java.util.concurrent.TimeUnit unit)
Waits for this future to be completed within the
specified time limit without interruption.
|
boolean |
cancel(boolean mayInterruptIfRunning)
If the cancellation was successful it will fail the future with a
CancellationException. |
java.lang.Throwable |
cause()
Returns the cause of the failed I/O operation if the I/O operation has
failed.
|
V |
getNow()
Return the result without blocking.
|
boolean |
isCancellable()
returns
true if and only if the operation can be cancelled via cancel(boolean). |
boolean |
isSuccess()
Returns
true if and only if the I/O operation was completed
successfully. |
Future<V> |
removeListener(GenericFutureListener<? extends Future<? super V>> listener)
Removes the first occurrence of the specified listener from this future.
|
Future<V> |
removeListeners(GenericFutureListener<? extends Future<? super V>>... listeners)
Removes the first occurrence for each of the listeners from this future.
|
Future<V> |
sync()
Waits for this future until it is done, and rethrows the cause of the failure if this future
failed.
|
Future<V> |
syncUninterruptibly()
Waits for this future until it is done, and rethrows the cause of the failure if this future
failed.
|
boolean isSuccess()
true if and only if the I/O operation was completed
successfully.boolean isCancellable()
true if and only if the operation can be cancelled via cancel(boolean).java.lang.Throwable cause()
null if succeeded or this future is not
completed yet.Future<V> addListener(GenericFutureListener<? extends Future<? super V>> listener)
Future<V> addListeners(GenericFutureListener<? extends Future<? super V>>... listeners)
Future<V> removeListener(GenericFutureListener<? extends Future<? super V>> listener)
Future<V> removeListeners(GenericFutureListener<? extends Future<? super V>>... listeners)
Future<V> sync() throws java.lang.InterruptedException
java.lang.InterruptedExceptionFuture<V> syncUninterruptibly()
Future<V> await() throws java.lang.InterruptedException
java.lang.InterruptedException - if the current thread was interruptedFuture<V> awaitUninterruptibly()
InterruptedException and
discards it silently.boolean await(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
true if and only if the future was completed within
the specified time limitjava.lang.InterruptedException - if the current thread was interruptedboolean await(long timeoutMillis)
throws java.lang.InterruptedException
true if and only if the future was completed within
the specified time limitjava.lang.InterruptedException - if the current thread was interruptedboolean awaitUninterruptibly(long timeout,
java.util.concurrent.TimeUnit unit)
InterruptedException and discards it silently.true if and only if the future was completed within
the specified time limitboolean awaitUninterruptibly(long timeoutMillis)
InterruptedException and discards it silently.true if and only if the future was completed within
the specified time limitV getNow()
null.
As it is possible that a null value is used to mark the future as successful you also need to check
if the future is really done with Future.isDone() and not rely on the returned null value.boolean cancel(boolean mayInterruptIfRunning)
CancellationException.cancel 在接口中 java.util.concurrent.Future<V>