T
- The result object type returned by this futurepublic class ListenableFutureTask<T> extends java.util.concurrent.FutureTask<T> implements ListenableRunnableFuture<T>, CallableContainer<T>
Executor
, and then return this future.Constructor and Description |
---|
ListenableFutureTask(boolean recurring,
java.util.concurrent.Callable<T> task)
Constructs a runnable future with a callable work unit.
|
ListenableFutureTask(boolean recurring,
java.lang.Runnable task)
Constructs a runnable future with a runnable work unit.
|
ListenableFutureTask(boolean recurring,
java.lang.Runnable task,
T result)
Constructs a runnable future with a runnable work unit.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(java.lang.Runnable listener)
Add a listener to be called once the future has completed.
|
void |
addListener(java.lang.Runnable listener,
java.util.concurrent.Executor executor)
Add a listener to be called once the future has completed.
|
java.util.concurrent.Callable<T> |
getContainedCallable()
Call to get the contained callable held within the wrapper.
|
void |
run() |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addCallback, addCallback, flatMap, flatMap, map, map
public ListenableFutureTask(boolean recurring, java.lang.Runnable task)
recurring
- boolean to indicate if this task can run multiple times, and thus must be reset after each runtask
- runnable to be runpublic ListenableFutureTask(boolean recurring, java.lang.Runnable task, T result)
recurring
- boolean to indicate if this task can run multiple times, and thus must be reset after each runtask
- runnable to be runresult
- result to be provide after run has completedpublic ListenableFutureTask(boolean recurring, java.util.concurrent.Callable<T> task)
recurring
- boolean to indicate if this task can run multiple times, and thus must be reset after each runtask
- callable to be runpublic void run()
public void addListener(java.lang.Runnable listener)
ListenableFuture
The listener from this call will execute on the same thread the result was produced on, or on
the adding thread if the future is already complete. If the runnable has high complexity,
consider using ListenableFuture.addListener(Runnable, Executor)
.
addListener
in interface ListenableFuture<T>
listener
- the listener to run when the computation is completepublic void addListener(java.lang.Runnable listener, java.util.concurrent.Executor executor)
ListenableFuture
If the provided Executor
is null, the listener will execute on the thread which
computed the original future (once it is done). If the future has already completed, the
listener will execute immediately on the thread which is adding the listener.
addListener
in interface ListenableFuture<T>
listener
- the listener to run when the computation is completeexecutor
- Executor
the listener should be ran on, or null
public java.util.concurrent.Callable<T> getContainedCallable()
CallableContainer
getContainedCallable
in interface CallableContainer<T>
null
if none is contained