public interface GenericFuture<V> extends Future<V>
| 限定符和类型 | 方法和说明 |
|---|---|
GenericFuture<V> |
addListener(GenericFutureListener<? extends GenericFuture<? super V>> listener)
Adds the specified listener to this future.
|
GenericFuture<V> |
addListeners(GenericFutureListener<? extends GenericFuture<? super V>>... listeners)
Adds the specified listeners to this future.
|
GenericFuture<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,
TimeUnit unit)
Waits for this future to be completed within the
specified time limit.
|
GenericFuture<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,
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. |
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. |
GenericFuture<V> |
removeListener(GenericFutureListener<? extends GenericFuture<? super V>> listener)
Removes the first occurrence of the specified listener from this future.
|
GenericFuture<V> |
removeListeners(GenericFutureListener<? extends GenericFuture<? super V>>... listeners)
Removes the first occurrence for each of the listeners from this future.
|
GenericFuture<V> |
sync()
Waits for this future until it is done, and rethrows the cause of the failure if this future
failed.
|
GenericFuture<V> |
syncUninterruptibly()
Waits for this future until it is done, and rethrows the cause of the failure if this future
failed.
|
get, get, isCancelled, isDoneboolean 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).Throwable cause()
null if succeeded or this future is not
completed yet.GenericFuture<V> addListener(GenericFutureListener<? extends GenericFuture<? super V>> listener)
GenericFuture<V> addListeners(GenericFutureListener<? extends GenericFuture<? super V>>... listeners)
GenericFuture<V> removeListener(GenericFutureListener<? extends GenericFuture<? super V>> listener)
GenericFuture<V> removeListeners(GenericFutureListener<? extends GenericFuture<? super V>>... listeners)
GenericFuture<V> sync() throws InterruptedException
GenericFuture<V> syncUninterruptibly()
GenericFuture<V> await() throws InterruptedException
InterruptedException - if the current thread was interruptedGenericFuture<V> awaitUninterruptibly()
InterruptedException and
discards it silently.boolean await(long timeout,
TimeUnit unit)
throws InterruptedException
true if and only if the future was completed within
the specified time limitInterruptedException - if the current thread was interruptedboolean await(long timeoutMillis)
throws InterruptedException
true if and only if the future was completed within
the specified time limitInterruptedException - if the current thread was interruptedboolean awaitUninterruptibly(long timeout,
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.Copyright © 2021. All rights reserved.