net.sourceforge.domian.util.concurrent.task
Class ConcurrentTaskExecutor<T extends Task>
java.lang.Object
net.sourceforge.domian.util.concurrent.task.ConcurrentTaskExecutor<T>
- Direct Known Subclasses:
- ConcurrentRepositoryTaskExecutor
public class ConcurrentTaskExecutor<T extends Task>
- extends java.lang.Object
Class offering concurrent execution of n
time-limited Task
threads
(in addition to the main thread that creates this executor instance).
The synchronizing mechanism is a CyclicBarrier
.
This executor creates two barriers; one for a synchronized start,
and a second one for letting all threads finish before the main thread (running this instance) continues.
- Since:
- 0.4
- Author:
- Eirik Torske
Field Summary |
protected java.util.concurrent.CyclicBarrier |
barrier
|
private org.slf4j.Logger |
log
|
protected java.util.concurrent.ExecutorService |
pool
|
protected java.util.List<T> |
taskList
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
private final org.slf4j.Logger log
pool
protected java.util.concurrent.ExecutorService pool
barrier
protected java.util.concurrent.CyclicBarrier barrier
taskList
protected java.util.List<T extends Task> taskList
ConcurrentTaskExecutor
public ConcurrentTaskExecutor()
addTask
public void addTask(T task)
getNumberOfTasks
public java.lang.Integer getNumberOfTasks()
updateTask
protected void updateTask(T task)
- Overridable method for updating custom task instances before execution.
reset
public void reset()
execute
public void execute()
throws java.util.concurrent.BrokenBarrierException,
java.lang.InterruptedException
- Throws:
java.util.concurrent.BrokenBarrierException
java.lang.InterruptedException
Copyright © 2006-2009. All Rights Reserved.