T - The futures' result typepublic class SquadExecutor<T>
extends java.lang.Object
implements java.util.concurrent.Executor
Executor which executes tasks through a delegate ExecutorService. The awaitCompletion()
methods waits until all tasks of the squad are complete.| Constructor and Description |
|---|
SquadExecutor(java.util.concurrent.ExecutorService delegate) |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<java.util.concurrent.Future<T>> |
awaitCompletion()
Returns when all tasks that were previously submitted with
submit(Callable), submit(Runnable,
Object), submit(Runnable, Object) and execute(Runnable) have completed. |
java.util.List<java.util.concurrent.Future<T>> |
awaitCompletion(long timeout,
java.util.concurrent.TimeUnit unit)
Returns when all tasks that were previously submitted with
submit(Callable), submit(Runnable,
Object), submit(Runnable, Object) and execute(Runnable) have completed, or when then
timeout expires. |
void |
execute(java.lang.Runnable command) |
java.util.concurrent.Future<T> |
submit(java.util.concurrent.Callable<T> task)
Submits a value-returning task for execution.
|
java.util.concurrent.Future<T> |
submit(java.lang.Runnable task)
Submits a
Runnable task for execution. |
java.util.concurrent.Future<T> |
submit(java.lang.Runnable task,
T result)
Submits a Runnable task for execution.
|
public SquadExecutor(java.util.concurrent.ExecutorService delegate)
SquadExecutorpublic void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executorpublic java.util.concurrent.Future<T> submit(java.lang.Runnable task)
Runnable task for execution.task - The task to submitpublic java.util.concurrent.Future<T> submit(java.lang.Runnable task, T result)
task - The task to submitresult - The result to returnpublic java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
task - The task to submitpublic java.util.List<java.util.concurrent.Future<T>> awaitCompletion() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.CancellationException
submit(Callable), submit(Runnable,
Object), submit(Runnable, Object) and execute(Runnable) have completed.java.util.concurrent.CancellationException - One of the tasks was cancelledjava.util.concurrent.ExecutionException - One of the tasks threw an exceptionjava.lang.InterruptedException - The current thread was interrupted while waitingpublic java.util.List<java.util.concurrent.Future<T>> awaitCompletion(long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.CancellationException, java.util.concurrent.ExecutionException, java.lang.InterruptedException
submit(Callable), submit(Runnable,
Object), submit(Runnable, Object) and execute(Runnable) have completed, or when then
timeout expires.java.util.concurrent.CancellationException - One of the tasks was cancelledjava.util.concurrent.ExecutionException - One of the tasks threw an exceptionjava.lang.InterruptedException - The current thread was interrupted while waiting