toolbox.queueing
Class Listener

Package class diagram package Listener
java.lang.Object
  extended by java.lang.Thread
      extended by toolbox.queueing.Listener
All Implemented Interfaces:
java.lang.Runnable

public class Listener
extends java.lang.Thread

The listener class provides a mechanism for dispatching events from the Queue class and a common way of handling events dispatched from the Queue class.


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 java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Listener(Queue queue, java.lang.ThreadGroup thrdGrp, int instance, Worker worker)
          Constructs a new Listener.
 
Method Summary
 void destroy()
          Destroys the Listener by destroying the member worker.
 void run()
          Dispatches events from the event queue and presents them to the member Worker.
 void stopListener()
          Stops the listener by flushing the event queue.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Listener

public Listener(Queue queue,
                java.lang.ThreadGroup thrdGrp,
                int instance,
                Worker worker)
Constructs a new Listener.

Parameters:
queue - Event queue.
thrdGrp - ThreadGroup to add listener to. Applications that extend the listener class must provide a thread group to add the listener to.
instance - Listener instance count used to name listeners. Must provided by the calling class.
worker - Worker implementation to perform tasks.
Method Detail

run

public void run()
Dispatches events from the event queue and presents them to the member Worker.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

stopListener

public void stopListener()
Stops the listener by flushing the event queue.


destroy

public void destroy()
Destroys the Listener by destroying the member worker.

Overrides:
destroy in class java.lang.Thread