de.jaetzold.util
Class TaskPerformer
java.lang.Object
|
+--java.lang.Thread
|
+--de.jaetzold.util.TaskPerformer
- All Implemented Interfaces:
- Runnable
- public class TaskPerformer
- extends Thread
A Thread which processes Tasks. It continuously tries to get Tasks from
its associated TaskQueue and calls their perform()
-method.
This call can return an Event or null.
Any results from that call or any Exceptions are posted to the resultEventQueue
of this TaskPerformer if it has any.
In parts a similar functionality could've been aquired by using java.util.Timer
and java.util.TimerTask
. But this code here therefor works in Java 1.1.x
and higher, and has some extra-features like the resultEventQueue and the associated
possibility of passing exceptions from this thread to another.
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
resultEventQueueMonitor
protected Object resultEventQueueMonitor
resultEventQueue
protected Queue resultEventQueue
taskQueue
protected Queue taskQueue
taskQueueMonitor
protected Object taskQueueMonitor
TaskPerformer
public TaskPerformer(Queue taskQueue)
getResultEventQueue
public Queue getResultEventQueue()
setResultEventQueue
public void setResultEventQueue(Queue resultEventQueue)
getTaskQueue
public Queue getTaskQueue()
setTaskQueue
public void setTaskQueue(Queue taskQueue)
interrupt
public void interrupt(Task task)
- Interrupts this Thread if it is currently processing the given Event.
If the given Event is
null
then this Thread is interrupted
if it is currently processing any Event.
This method should be used instead of interrupt()
, because
there should be no reason to interrupt this Thread while doing other things
apart from processing an Event.
endPerforming
public void endPerforming()
haltPerforming
public void haltPerforming()
haltPerforming
public void haltPerforming(boolean interruptAndWait)
waitForHalt
public void waitForHalt()
throws InterruptedException
resumePerforming
public void resumePerforming()
run
public void run()
- Overrides:
run
in class Thread