org.exolab.jms.util
Class BlockingWorkerQueue

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--org.exolab.jms.util.BlockingWorkerQueue
All Implemented Interfaces:
java.lang.Runnable

public class BlockingWorkerQueue
extends java.lang.Thread

A BlockingWorkerQueue is attached to a QueueWorker. Any thread can add work to the queue. The BlockingWorkerQueue, which extends Thread, blocks waiting for work to arrive. When work arrives it will be dequeued and passed down to the QueueWorker for processing.

The owner can use close to gracefully shutdown the thread.

Version:
$Revision: 1.4 $ $Date: 2003/08/07 13:33:12 $
Author:
Jim Alateras

Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
BlockingWorkerQueue(java.lang.String name, QueueWorker worker)
          Construct a blocking worker queue and attahc to the specified queue worker.
 
Method Summary
 void add(java.lang.Object object)
          Add some work to the end of the queue
 void close()
          Close this worker queue
 void run()
          This method is called once the thread has started.
 int size()
          Return the number of entries still on the queue
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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

BlockingWorkerQueue

public BlockingWorkerQueue(java.lang.String name,
                           QueueWorker worker)
Construct a blocking worker queue and attahc to the specified queue worker. Make the thread a deamon thread.
Parameters:
name - - the name of the thread
worker - - the queue worker attached to this queue
Method Detail

add

public void add(java.lang.Object object)
Add some work to the end of the queue
Parameters:
work - - add this piece of work

run

public void run()
This method is called once the thread has started. It basically loops forever removing work from the queue and passing it to the runnable.

Calling close on this object will terminate it.

Overrides:
run in class java.lang.Thread

size

public int size()
Return the number of entries still on the queue

close

public void close()
Close this worker queue


Copyright © 1999-2004 The OpenJMS Group. All Rights Reserved.