public final class SettableFuture<V> extends AbstractFuture<V>
ListenableFuture
whose result may be set by a set(Object)
or setException(Throwable)
call. It may also be cancelled.ValueFuture
)Modifier and Type | Method and Description |
---|---|
static <V> SettableFuture<V> |
create()
Creates a new
SettableFuture in the default state. |
boolean |
set(V value)
Sets the value of this future.
|
boolean |
setException(Throwable throwable)
Sets the future to having failed with the given exception.
|
addListener, cancel, get, get, isCancelled, isDone
public static <V> SettableFuture<V> create()
SettableFuture
in the default state.public boolean set(V value)
true
if
the value was successfully set, or false
if the future has already
been set or cancelled.value
- the value the future should hold.public boolean setException(Throwable throwable)
ExecutionException
and thrown from the get
methods. This method will return true
if the exception was
successfully set, or false
if the future has already been set or
cancelled.throwable
- the exception the future should hold.Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.