@Beta public abstract class AbstractListeningExecutorService extends AbstractExecutorService implements ListeningExecutorService
ListeningExecutorService implementation that creates
ListenableFutureTask instances for each Runnable and Callable submitted
to it. These tasks are run with the abstract execute(Runnable) method.
In addition to Executor.execute(java.lang.Runnable), subclasses must implement all methods related to shutdown and
termination.
| Constructor and Description |
|---|
AbstractListeningExecutorService() |
| Modifier and Type | Method and Description |
|---|---|
protected <T> ListenableFutureTask<T> |
newTaskFor(Callable<T> callable)
Returns a RunnableFuture for the given callable task.
|
protected <T> ListenableFutureTask<T> |
newTaskFor(Runnable runnable,
T value)
Returns a RunnableFuture for the given runnable and default
value.
|
<T> ListenableFuture<T> |
submit(Callable<T> task)
Submits a value-returning task for execution and returns a
Future representing the pending results of the task.
|
ListenableFuture<?> |
submit(Runnable task)
Submits a Runnable task for execution and returns a Future
representing that task.
|
<T> ListenableFuture<T> |
submit(Runnable task,
T result)
Submits a Runnable task for execution and returns a Future
representing that task.
|
invokeAll, invokeAll, invokeAny, invokeAnyclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinvokeAll, invokeAllawaitTermination, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNowpublic AbstractListeningExecutorService()
protected final <T> ListenableFutureTask<T> newTaskFor(Runnable runnable, T value)
java.util.concurrent.AbstractExecutorServicenewTaskFor in class AbstractExecutorServicerunnable - the runnable task being wrappedvalue - the default value for the returned futureprotected final <T> ListenableFutureTask<T> newTaskFor(Callable<T> callable)
java.util.concurrent.AbstractExecutorServicenewTaskFor in class AbstractExecutorServicecallable - the callable task being wrappedpublic ListenableFuture<?> submit(Runnable task)
java.util.concurrent.ExecutorServicesubmit in interface ListeningExecutorServicesubmit in interface ExecutorServicesubmit in class AbstractExecutorServicetask - the task to submitpublic <T> ListenableFuture<T> submit(Runnable task, @Nullable T result)
java.util.concurrent.ExecutorServicesubmit in interface ListeningExecutorServicesubmit in interface ExecutorServicesubmit in class AbstractExecutorServicetask - the task to submitresult - the result to returnpublic <T> ListenableFuture<T> submit(Callable<T> task)
java.util.concurrent.ExecutorServiceIf you would like to immediately block waiting for a task, you can use constructions of the form result = exec.submit(aCallable).get();
Note: The Executors class includes a set of methods
that can convert some other common closure-like objects,
for example, PrivilegedAction to
Callable form so they can be submitted.
submit in interface ListeningExecutorServicesubmit in interface ExecutorServicesubmit in class AbstractExecutorServicetask - the task to submitCopyright © 2010-2013. All Rights Reserved.