waba.applet
Class Queue
java.lang.Object
|
+--waba.applet.Queue
- public class Queue
- extends java.lang.Object
Implements a simple FIFO queue of unlimited size. This queue is thread safe,
including functionality that allows one thread to wait for another to push an
object onto the queue.
|
Constructor Summary |
Queue()
|
|
Method Summary |
int |
getSize()
|
java.lang.Object |
pop()
Returns the oldest object in the queue. |
java.lang.Object |
popWait()
Returns the oldest object in the queue. |
java.lang.Object |
popWait(int maxTime)
Returns the oldest object in the queue. |
void |
push(java.lang.Object o)
Push an object on the queue and notify any waiting threads. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Queue
public Queue()
push
public void push(java.lang.Object o)
- Push an object on the queue and notify any waiting threads.
- Parameters:
o - object to push onto the queue
pop
public java.lang.Object pop()
- Returns the oldest object in the queue.
- Returns:
- oldest object in the queue or null if no objects in the queue
- See Also:
popWait(),
popWait(int)
popWait
public java.lang.Object popWait()
- Returns the oldest object in the queue. If the queue is empty, then this method
will block until another thread pushes an object onto the queue.
- Returns:
- oldest object in the queue
- See Also:
pop(),
popWait(int)
popWait
public java.lang.Object popWait(int maxTime)
- Returns the oldest object in the queue. If there are no object in the queue,
then this method will block until an object is placed in the queue from another
thread, or the specified time expires. If the time expires and no object has
been placed in the queue, this method will return null.
- Parameters:
maxTime - maximum amount of time, in ms, to wait for an object to placed in the queue- Returns:
- oldest object in the queue, or null if the specified time expires and no objects
have been placed in queue.
- See Also:
pop(),
popWait()
getSize
public int getSize()