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.ListenableFuture.ListenerOptimizationStrategy| 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.util.concurrent.Callable<T> task,
java.util.concurrent.Executor executingExecutor)
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,
java.util.concurrent.Executor executingExecutor)
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.
|
ListenableFutureTask(boolean recurring,
java.lang.Runnable task,
T result,
java.util.concurrent.Executor executingExecutor)
Constructs a runnable future with a runnable work unit.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(java.lang.Runnable listener,
java.util.concurrent.Executor executor,
ListenableFuture.ListenerOptimizationStrategy optimize)
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, waitaddCallback, addCallback, addCallback, addListener, addListener, flatMap, flatMap, flatMap, map, map, map, throwMap, throwMap, throwMappublic 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 ListenableFutureTask(boolean recurring,
java.lang.Runnable task,
java.util.concurrent.Executor executingExecutor)
recurring - boolean to indicate if this task can run multiple times, and thus must be reset after each runtask - runnable to be runexecutingExecutor - Executor task will be run on for possible listener optimization, or nullpublic ListenableFutureTask(boolean recurring,
java.lang.Runnable task,
T result,
java.util.concurrent.Executor executingExecutor)
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 completedexecutingExecutor - Executor task will be run on for possible listener optimization, or nullpublic ListenableFutureTask(boolean recurring,
java.util.concurrent.Callable<T> task,
java.util.concurrent.Executor executingExecutor)
recurring - boolean to indicate if this task can run multiple times, and thus must be reset after each runtask - callable to be runexecutingExecutor - Executor task will be run on for possible listener optimization, or nullpublic void run()
public void addListener(java.lang.Runnable listener,
java.util.concurrent.Executor executor,
ListenableFuture.ListenerOptimizationStrategy optimize)
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.
Caution should be used when choosing to optimize the listener execution. If the listener is
complex, or wanting to be run concurrent, this optimization could prevent that. In addition
it will prevent other listeners from potentially being invoked until it completes. However
if the listener is small / fast, this can provide significant performance gains. It should
also be known that not all ListenableFuture implementations may be able to do such an
optimization. Please see ListenableFuture.ListenerOptimizationStrategy javadocs for more specific
details of what optimizations are available.
addListener in interface ListenableFuture<T>listener - the listener to run when the computation is completeexecutor - Executor the listener should be ran on, or nulloptimize - true to avoid listener queuing for execution if already on the desired poolpublic java.util.concurrent.Callable<T> getContainedCallable()
CallableContainergetContainedCallable in interface CallableContainer<T>null if none is contained