T - The futures' result typepublic class SquadExecutor<T> extends Object implements 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(ExecutorService delegate) |
| Modifier and Type | Method and Description |
|---|---|
List<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. |
List<Future<T>> |
awaitCompletion(long timeout,
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(Runnable command) |
Future<T> |
submit(Callable<T> task)
Submits a value-returning task for execution.
|
Future<T> |
submit(Runnable task)
Submits a
Runnable task for execution. |
Future<T> |
submit(Runnable task,
T result)
Submits a Runnable task for execution.
|
public SquadExecutor(ExecutorService delegate)
SquadExecutorpublic Future<T> submit(@Nullable Runnable task)
Runnable task for execution.task - The task to submitpublic Future<T> submit(@Nullable Runnable task, T result)
task - The task to submitresult - The result to returnpublic Future<T> submit(@Nullable Callable<T> task)
task - The task to submitpublic List<Future<T>> awaitCompletion() throws InterruptedException, ExecutionException, CancellationException
submit(Callable), submit(Runnable,
Object), submit(Runnable, Object) and execute(Runnable) have completed.CancellationException - One of the tasks was cancelledExecutionException - One of the tasks threw an exceptionInterruptedException - The current thread was interrupted while waitingpublic List<Future<T>> awaitCompletion(long timeout, TimeUnit unit) throws CancellationException, ExecutionException, InterruptedException
submit(Callable), submit(Runnable,
Object), submit(Runnable, Object) and execute(Runnable) have completed, or when then
timeout expires.CancellationException - One of the tasks was cancelledExecutionException - One of the tasks threw an exceptionInterruptedException - The current thread was interrupted while waitingCopyright © 2018 Arno Unkrig. All rights reserved.