com.jthomas.util
Class Queue

java.lang.Object
  |
  +--com.jthomas.util.Queue

public class Queue
extends java.lang.Object

This class implements a simple efficient FIFO Queue.

   Usage Example:
	 Thread1:
      Queue myqueue = new Queue(100);
      myqueue.put("This could be any Object");
   Thread2:
      String x = (String)myqueue.get();
 
Notes:
A previous version of this was implemented with by extending a Vector. But this should be more efficient and has the builtin feature(limitation) that it limits the length of the queue. When the array is full, then queue.put(obj) will block until the next element has been gotten.

Author:
John Thomas

Constructor Summary
Queue()
          Queue Constructor.
Queue(int capacity)
          Queue Constructor that sets the capacity of the Queue.
 
Method Summary
 java.lang.Object get()
          Method: get() will return the first object in the Queue.
 void put(java.lang.Object obj)
          Method: put(Object obj) will place specified object into the FIFO Queue
 java.lang.String toString()
          Give Debug info
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Queue Constructor.


Queue

public Queue(int capacity)
Queue Constructor that sets the capacity of the Queue. When this many items are "put" to the queue, then it will block.

Method Detail

get

public java.lang.Object get()
Method: get() will return the first object in the Queue.

If the queue is empty, it will block until a new object arrives.

Returns:
Object It will return the next Object in the Queue.

put

public void put(java.lang.Object obj)
Method: put(Object obj) will place specified object into the FIFO Queue

Parameters:
obj - An Object that is to be added to the queue.
Returns:
void

toString

public java.lang.String toString()
Give Debug info

Overrides:
toString in class java.lang.Object