com.funambol.util
Class Queue

java.lang.Object
  extended by com.funambol.util.Queue

public class Queue
extends java.lang.Object

A multithreaded queue used for implementing producer-consumer style threading patterns. Multiple threads can wait for runnable objects being added to the queue while other threads add to the queue.


Constructor Summary
Queue()
           
 
Method Summary
 void add(java.lang.Object runnable)
          adds a runnable object to the end of the queue.
 java.lang.Object remove()
          Removes the first runnable object from the queue, blocking until one is available.
 java.lang.Object removeNoWait()
          Removes the first runnable object from the queue without blocking.
 int size()
          Returns the current number of runnable objects in the queue
 
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

size

public int size()
Returns the current number of runnable objects in the queue


add

public void add(java.lang.Object runnable)
adds a runnable object to the end of the queue. At least one thread will be notified.


remove

public java.lang.Object remove()
Removes the first runnable object from the queue, blocking until one is available.


removeNoWait

public java.lang.Object removeNoWait()
Removes the first runnable object from the queue without blocking. This method will return immediately with an item from the queue or null.

Returns:
the first runnable object removed from the queue or null if the queue is empty


Copyright © 2001-2009 Funambol.