com.quadrique.jbuildingblocks.core.thread
Class JbbBlockingFifoQueue

java.lang.Object
  extended by com.quadrique.jbuildingblocks.core.thread.JbbBlockingFifoQueue

public class JbbBlockingFifoQueue
extends Object

This is a thread-safe blocking FIFO queue (a calling thread will be blocked until there is an object that can be removed from the queue). Objects are removed from the queue in FIFO order.

Version:
1.0.0
Author:
Hervé Rivere

Method Summary
 void add(Object zObject)
          Add an object at the end of the collection
 boolean isEmpty()
           
static JbbBlockingFifoQueue newInstance()
           
 Object remove()
          Remove the FIFO object from the queue.
 void shutdown()
          Shutdowns the blocking queue by releasing all blocked threads (they will return from remove() with a null reference) and setting up the internal flag to prevent any additional Object to be added
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static JbbBlockingFifoQueue newInstance()

add

public final void add(Object zObject)
Add an object at the end of the collection

Parameters:
zObject - the Object instance to add to the queue

remove

public final Object remove()
Remove the FIFO object from the queue. If there is no object in the queue, the method BLOCKS until an object is enqueued or another thread calls the shutdown() method (in which case, a null reference will be returned).

Returns:
a reference to the FIFO object or null (if shutdown() has been called by another thread)

isEmpty

public final boolean isEmpty()
Returns:
true if the queue is empty, false otherwise

shutdown

public void shutdown()
Shutdowns the blocking queue by releasing all blocked threads (they will return from remove() with a null reference) and setting up the internal flag to prevent any additional Object to be added



Copyright © 2001-2008 Quadrique Corporation. All Rights Reserved.