@Beta public abstract class AbstractListeningExecutorService extends Object implements ListeningExecutorService
ListeningExecutorService
execution methods atop the abstract Executor.execute(java.lang.Runnable)
method. More concretely, the submit
, invokeAny
and invokeAll
methods
create ListenableFutureTask
instances and pass them to Executor.execute(java.lang.Runnable)
.
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 |
---|---|
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks) |
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit) |
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks) |
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit) |
<T> ListenableFuture<T> |
submit(Callable<T> task) |
ListenableFuture<?> |
submit(Runnable task) |
<T> ListenableFuture<T> |
submit(Runnable task,
T result) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
awaitTermination, isShutdown, isTerminated, shutdown, shutdownNow
public AbstractListeningExecutorService()
public ListenableFuture<?> submit(Runnable task)
submit
in interface ListeningExecutorService
submit
in interface ExecutorService
ListenableFuture
representing pending completion of the taskpublic <T> ListenableFuture<T> submit(Runnable task, @Nullable T result)
submit
in interface ListeningExecutorService
submit
in interface ExecutorService
ListenableFuture
representing pending completion of the taskpublic <T> ListenableFuture<T> submit(Callable<T> task)
submit
in interface ListeningExecutorService
submit
in interface ExecutorService
ListenableFuture
representing pending completion of the taskpublic <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
invokeAny
in interface ExecutorService
InterruptedException
ExecutionException
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
invokeAny
in interface ExecutorService
InterruptedException
ExecutionException
TimeoutException
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
ListeningExecutorService
All elements in the returned list must be ListenableFuture
instances.
invokeAll
in interface ListeningExecutorService
invokeAll
in interface ExecutorService
ListenableFuture
instances representing the tasks, in the same
sequential order as produced by the iterator for the given task list, each of which has
completed.InterruptedException
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
ListeningExecutorService
All elements in the returned list must be ListenableFuture
instances.
invokeAll
in interface ListeningExecutorService
invokeAll
in interface ExecutorService
ListenableFuture
instances representing the tasks, in the same
sequential order as produced by the iterator for the given task list. If the operation
did not time out, each task will have completed. If it did time out, some of these
tasks will not have completed.InterruptedException
Copyright © 2010-2013. All Rights Reserved.