|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
de.nava.informa.utils.toolkit.WorkerThread
public abstract class WorkerThread
Abstract worker thread which is driven by WorkersManager. Worker thread runs
until terminate property is set to true. All of the threads are run in
daemon mode and do not prevent application from sudden quit.
In order to do something useful with channel this class should be extended with implementation
of process() method. This method is invoked each time the thread receives new
processing task. Current class takes care of getting new tasks, marking busy state and
other necessary tasks.
After the task is finished worker checks JobSourceIF object (if specified)
to get new assignments and it there's no job goes to sleep for a IDLE_SLEEP_TIME
milliseconds. When manager finds new task it immediately awakens the thread. If the thread
doesn't receive new assignments for an IDLE_SLEEP_TIME it checks the
JobSourceIF object again by itself to find new task. This is done for greater
safety reasons to avoid situations when the queue is full of tasks and workers are in endless
sleep.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
Thread.State, Thread.UncaughtExceptionHandler |
| Field Summary |
|---|
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
WorkerThread(String name)
Creates named worker thread. |
|
| Method Summary | |
|---|---|
ChannelRecord |
getChannelInProcess()
Returns channel which is currently in processing. |
protected abstract void |
processRecord(ChannelRecord record)
Processes record. |
void |
run()
If this thread was constructed using a separate Runnable run object, then that
Runnable object's run method is called;
otherwise, this method does nothing and returns. |
void |
setQueue(org.apache.commons.collections.Buffer queue)
Sets the queue of tasks. |
void |
terminate()
Marks this thread for termination on job completion. |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public WorkerThread(String name)
name - name of the thread.| Method Detail |
|---|
public final void terminate()
public final ChannelRecord getChannelInProcess()
public final void run()
Runnable run object, then that
Runnable object's run method is called;
otherwise, this method does nothing and returns.
Subclasses of Thread should override this method.
run in interface Runnablerun in class ThreadThread.start(),
Thread.Thread(ThreadGroup, Runnable, String),
Runnable.run()protected abstract void processRecord(ChannelRecord record)
record - record to process.public void setQueue(org.apache.commons.collections.Buffer queue)
queue - blocking queue of tasks.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||