Class ExecutionGroup
java.lang.Object
com.complexible.common.util.concurrent.ExecutionGroup
A very light-weight utility class to make it easier to run a set of tasks together and wait until all those jobs end.
The tasks can be run concurrently or sequentially depending on what kind of group has been created.
- Since:
- 0.9
- Version:
- 2.0
- Author:
- Evren Sirin, Michael Grove
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ExecutionGroupconcurrent(ExecutorService theExecutorService) execute()voidabstract voidexecuteAndWait(boolean theUninterruptible) Waits until all the tasks of this group have finished.abstract booleanprotected abstract voidperformAdd(Callable<?> theTask) static ExecutionGroup
-
Constructor Details
-
ExecutionGroup
public ExecutionGroup()
-
-
Method Details
-
add
-
addAll
-
addAll
-
performAdd
-
executeAndWait
-
executeAndWait
public abstract void executeAndWait(boolean theUninterruptible) throws ExecutionException, InterruptedException Waits until all the tasks of this group have finished.- Parameters:
theUninterruptible- if true, the wait is not abandoned when the calling thread gets interrupted (the interrupt status is restored before returning) and thus never returns while a task can still be running. Pass true when the tasks work on resources whose lifetime is bound to the caller, so abandoning them is not an option; such tasks have to stop cooperatively, e.g. via a cancellation check they share with the caller. If false, an interrupt cancels the futures and returns immediately, which does not mean that the tasks have stopped.- Throws:
ExecutionExceptionInterruptedException
-
execute
-
isExecuting
public abstract boolean isExecuting() -
concurrent
-
sequential
-