com.lti.utils.synchronization
Class MessageDrivenThread

java.lang.Object
  extended by java.lang.Thread
      extended by com.lti.utils.synchronization.CloseableThread
          extended by com.lti.utils.synchronization.MessageDrivenThread
All Implemented Interfaces:
java.lang.Runnable

public class MessageDrivenThread
extends CloseableThread

A useful base class for a thread that wishes to simply respond to messages.

Author:
Ken Larson

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class com.lti.utils.synchronization.CloseableThread
closing
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MessageDrivenThread(java.lang.ThreadGroup group, java.lang.String threadName)
           
MessageDrivenThread(java.lang.ThreadGroup group, java.lang.String threadName, MessageDrivenThreadListener listener)
           
 
Method Summary
protected  void doMessageReceived(java.lang.Object o)
          subclass should override to do message processing.
 void post(java.lang.Object msg)
           
 void run()
           
 void setListener(MessageDrivenThreadListener listener)
           
 
Methods inherited from class com.lti.utils.synchronization.CloseableThread
close, isClosed, isClosing, setClosed, setClosing, waitUntilClosed
 
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

MessageDrivenThread

public MessageDrivenThread(java.lang.ThreadGroup group,
                           java.lang.String threadName,
                           MessageDrivenThreadListener listener)

MessageDrivenThread

public MessageDrivenThread(java.lang.ThreadGroup group,
                           java.lang.String threadName)
Method Detail

setListener

public void setListener(MessageDrivenThreadListener listener)

post

public void post(java.lang.Object msg)
          throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

doMessageReceived

protected void doMessageReceived(java.lang.Object o)
subclass should override to do message processing.