|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jlf.log.QueueProcessor
The QueueProcessor
class is an abstract class designed to
offload the processing of a set of items to another thread. Any number
of producers from any number of threads can enqueue items to the
queue processor. Upon enqueuing the first item, the queue processor
will start a thread to process any items added to the queue. To use
all of this capability, all you need do is subclass this class
and implement the abstract processItem()
method.
Field Summary | |
protected static long |
NEVER_TIME_OUT_WAIT
Constant to set the processor so it never times out while waiting for a request. |
protected java.util.Vector |
processorQueue
This is a queue for the processor thread to use when processing the items. |
protected java.lang.Thread |
processorThread
Holds the thread processing items queued. |
protected java.util.Vector |
producerQueue
This is a queue for producer threads to add items that need processing. |
protected long |
timeOutInMilliseconds
Timeout where the processor should wake up every so often to process events. |
Constructor Summary | |
QueueProcessor()
Default constructor, starts the thread processing queue items. |
Method Summary | |
void |
enqueue(java.lang.Object itemToBeProcessed)
Adds an item to be processed, returning as quickly as possible so the calling thread doesn't have to wait for the item to be processed. |
protected abstract void |
processItem(java.lang.Object queueItem)
Override this method to process any items your producers have queued. |
protected void |
processQueueItems()
Iterates through the collection of processorQueue items to process them. |
void |
run()
Main method to process the queue. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final long NEVER_TIME_OUT_WAIT
protected long timeOutInMilliseconds
protected java.util.Vector producerQueue
protected java.util.Vector processorQueue
protected java.lang.Thread processorThread
Constructor Detail |
public QueueProcessor()
Method Detail |
public void enqueue(java.lang.Object itemToBeProcessed)
public void run()
processItem()
method instead!
run
in interface java.lang.Runnable
protected void processQueueItems()
protected abstract void processItem(java.lang.Object queueItem)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |