jsync
Class Queue

java.lang.Object
  extended byjsync.Queue

public class Queue
extends java.lang.Object

First-In First-Out queue for synchronizing data exchange between several threads. For example, producer/consumer problem can be implemented by means of this queue.


Constructor Summary
Queue()
           
 
Method Summary
 java.lang.Object get()
          Wait until queue is not empty and take object from the queue.
 java.lang.Object get(long timeout)
          Wait at most timeout miliseconds until queue becomes not empty and take object from the queue.
 boolean isEmpty()
          Check if queue is empty.
 void put(java.lang.Object obj)
          Put object in queue.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Method Detail

put

public void put(java.lang.Object obj)
Put object in queue. Notify data consumers.


get

public java.lang.Object get()
Wait until queue is not empty and take object from the queue.

Returns:
object which was inserted in the queue the longest time ago.

get

public java.lang.Object get(long timeout)
Wait at most timeout miliseconds until queue becomes not empty and take object from the queue.

Parameters:
timeout - the maximum time to wait in milliseconds.
Returns:
object if queue is not empty, null otherwise

isEmpty

public boolean isEmpty()
Check if queue is empty.