public class WorkerThread
extends java.lang.Thread
| Modifier and Type | Field and Description |
|---|---|
private static boolean |
ENABLE_DEBUG
Enables debug output of major events.
|
private static boolean |
ENABLE_DETAIL_DEBUG
Enables debug output of minor events.
|
private boolean |
m_alive
True if this thread is alive and not scheduled for shutdown.
|
private boolean |
m_clearInterruptFlag
True if this thread needs to clear the interrupt flag
|
private AbstractThreadPool |
m_pool
The thread pool this thread is associated with.
|
private DefaultThreadControl |
m_threadControl
The thread control associated with current work.
|
private org.apache.excalibur.thread.Executable |
m_work
The work currentlyy associated with worker (May be null).
|
| Modifier | Constructor and Description |
|---|---|
protected |
WorkerThread(AbstractThreadPool pool,
java.lang.ThreadGroup group,
java.lang.String name)
Allocates a new
Worker object. |
| Modifier and Type | Method and Description |
|---|---|
void |
clearInterruptFlag()
Clears the interrupt flag for this thread.
|
protected void |
debug(java.lang.String message)
Used to log major events against the worker.
|
protected void |
debug(java.lang.String message,
java.lang.Throwable throwable)
Used to log major events against the worker.
|
protected void |
detailDebug(java.lang.String message)
Used to log minor events against the worker.
|
protected void |
detailDebug(java.lang.String message,
java.lang.Throwable throwable)
Used to log minor events against the worker.
|
void |
dispose()
Set the alive variable to false causing the worker to die.
|
protected org.apache.excalibur.thread.ThreadControl |
execute(org.apache.excalibur.thread.Executable work)
Set the Work code this Worker must
execute and notifies its thread to do it.
|
protected void |
executeAndWait(org.apache.excalibur.thread.Executable work)
Set the Work code this Worker must
execute and notifies its thread to do it.
|
protected void |
postExecute()
Overide this method to execute something after
each bit of "work".
|
protected void |
preExecute()
Overide this method to execute something before
each bit of "work".
|
protected void |
recycleThread()
Implement this method to replace thread back into pool.
|
void |
run()
The main execution loop.
|
private void |
waitForWork()
For for new work to arrive or for the thread to be destroyed.
|
activeCount, checkAccess, clone, 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, yieldprivate static final boolean ENABLE_DEBUG
private static final boolean ENABLE_DETAIL_DEBUG
private org.apache.excalibur.thread.Executable m_work
private DefaultThreadControl m_threadControl
private boolean m_alive
private boolean m_clearInterruptFlag
private final AbstractThreadPool m_pool
protected WorkerThread(AbstractThreadPool pool, java.lang.ThreadGroup group, java.lang.String name)
Worker object.public final void run()
run in interface java.lang.Runnablerun in class java.lang.Threadprotected void recycleThread()
protected void postExecute()
protected void preExecute()
public void clearInterruptFlag()
public void dispose()
This is called by the pool when it is removed.
protected org.apache.excalibur.thread.ThreadControl execute(org.apache.excalibur.thread.Executable work)
protected void executeAndWait(org.apache.excalibur.thread.Executable work)
private void waitForWork()
protected void debug(java.lang.String message)
This implementation is a Noop. Subclasses can override to actually do some logging.
message - Message to log.protected void debug(java.lang.String message,
java.lang.Throwable throwable)
This implementation is a Noop. Subclasses can override to actually do some logging.
message - Message to log.throwable - Throwable to log with the message.protected void detailDebug(java.lang.String message)
This implementation is a Noop. Subclasses can override to actually do some logging.
message - Message to log.protected void detailDebug(java.lang.String message,
java.lang.Throwable throwable)
This implementation is a Noop. Subclasses can override to actually do some logging.
message - Message to log.throwable - Throwable to log with the message.