net.pakl.rl
Class Queue

java.lang.Object
  extended by net.pakl.rl.Queue

public class Queue
extends java.lang.Object

This class is a synchronized queue (FIFO) data structure. It is often used to transfer objects between threads. NB: Do NOT attempt code like: if(!queue.isEmpty()) foo = queue.get(); It is not thread-safe, even though isEmpty() and get() are synchronized. It is possible for a thread to sneak in after the call to isEmpty() and before the call to get(). If you must do this, use something like: synchronized(queue) { if(!queue.isEmpty()) foo.queue.get(); } The same applies to using size() and get().


Constructor Summary
Queue()
           
 
Method Summary
 java.lang.Object get()
           
 java.lang.Object get(long timeout)
          get an object off of the front of the queue
 boolean isEmpty()
           
 void put(java.lang.Object v)
          place an object onto the end of the queue
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Method Detail

put

public void put(java.lang.Object v)
place an object onto the end of the queue


get

public java.lang.Object get(long timeout)
get an object off of the front of the queue


get

public java.lang.Object get()

isEmpty

public boolean isEmpty()

size

public int size()