|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object x10.util.ThreadSafeQueue
ThreadSafeQueue this is an implementation of a First In First Out (FIFO) data structure. This class uses synchronization to provide thread safety for adding and removing objects to and from the queue. All of the methods in this class are synchronized, therefore temporary thread blocking might occur when calling any of these methods.
Constructor Summary | |
ThreadSafeQueue()
ThreadSafeQueue constructs an empty ThreadSafeQueue |
Method Summary | |
java.lang.Object |
dequeue()
dequeue removes and returns the first object in the queue without blocking. |
void |
dequeue(java.lang.Object toDequeue)
dequeue removes the specified object from the queue if and only if the specified object is the first object in the queue. |
java.lang.Object |
dequeueNextAvailable()
dequeueNextAvailable blocks until the next object becomes available to the queue. |
void |
empty()
empty completely removes all objects that are currently in the queue. |
void |
enqueue(java.lang.Object element)
enqueue adds the specified object to the end of the queue |
java.lang.Object |
peek()
peek returns the next available object in the queue without physically removing the object from the queue. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ThreadSafeQueue()
Method Detail |
public void enqueue(java.lang.Object element)
element
- the object to be added to the end of the queuepublic java.lang.Object dequeueNextAvailable() throws java.lang.InterruptedException
java.lang.InterruptedException
- if the blocked thread is interrupted
before an object becomes available.public java.lang.Object dequeue()
public java.lang.Object peek()
public void dequeue(java.lang.Object toDequeue)
toDequeue
- the object to dequeuepublic void empty()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |