com.google.common.util.concurrent
Class AbstractListeningExecutorService
java.lang.Object
com.google.common.util.concurrent.AbstractListeningExecutorService
- All Implemented Interfaces:
- ListeningExecutorService, java.util.concurrent.Executor, java.util.concurrent.ExecutorService
@Beta
public abstract class AbstractListeningExecutorService
- extends java.lang.Object
- implements ListeningExecutorService
Implements 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.
- Since:
- 14.0
|
Method Summary |
<T> java.util.List<java.util.concurrent.Future<T>> |
|
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
|
<T> java.util.List<java.util.concurrent.Future<T>> |
|
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
|
|
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
|
|
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
|
|
submit(java.util.concurrent.Callable<T> task)
|
ListenableFuture<?> |
submit(java.lang.Runnable task)
|
|
submit(java.lang.Runnable task,
T result)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.concurrent.ExecutorService |
awaitTermination, isShutdown, isTerminated, shutdown, shutdownNow |
| Methods inherited from interface java.util.concurrent.Executor |
execute |
AbstractListeningExecutorService
public AbstractListeningExecutorService()
submit
public ListenableFuture<?> submit(java.lang.Runnable task)
- Specified by:
submit in interface ListeningExecutorService- Specified by:
submit in interface java.util.concurrent.ExecutorService
- Returns:
- a
ListenableFuture representing pending completion of the task
submit
public <T> ListenableFuture<T> submit(java.lang.Runnable task,
@Nullable
T result)
- Specified by:
submit in interface ListeningExecutorService- Specified by:
submit in interface java.util.concurrent.ExecutorService
- Returns:
- a
ListenableFuture representing pending completion of the task
submit
public <T> ListenableFuture<T> submit(java.util.concurrent.Callable<T> task)
- Specified by:
submit in interface ListeningExecutorService- Specified by:
submit in interface java.util.concurrent.ExecutorService
- Returns:
- a
ListenableFuture representing pending completion of the task
invokeAny
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
- Specified by:
invokeAny in interface java.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
invokeAny
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.TimeoutException
- Specified by:
invokeAny in interface java.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
invokeAll
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
throws java.lang.InterruptedException
- Description copied from interface:
ListeningExecutorService
-
All elements in the returned list must be ListenableFuture instances.
- Specified by:
invokeAll in interface ListeningExecutorService- Specified by:
invokeAll in interface java.util.concurrent.ExecutorService
- Returns:
- A list of
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.
- Throws:
java.lang.InterruptedException
invokeAll
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
- Description copied from interface:
ListeningExecutorService
-
All elements in the returned list must be ListenableFuture instances.
- Specified by:
invokeAll in interface ListeningExecutorService- Specified by:
invokeAll in interface java.util.concurrent.ExecutorService
- Returns:
- a list of
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.
- Throws:
java.lang.InterruptedException