|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimple.util.MessageQueue
public class MessageQueue
This provides a means to pass messages between threads. This
can be given an arbitrary number of messages from a notifier
thread without blocking so that message passing is not a
time consuming task. The recieving thread can then acquire
the messages using the dequeue
method which
will block if there are no messages in the queue.
LinkedList
Constructor Summary | |
---|---|
MessageQueue()
This creates a new MessageQueue object for
passing messages between threads. |
Method Summary | |
---|---|
java.lang.Object |
dequeue()
This is guaranteed to return an object. |
void |
enqueue(java.lang.Object value)
If this enqueues to an empty queue it notifys any dequeuers that were trying to take from the empty queue. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MessageQueue()
MessageQueue
object for
passing messages between threads. This synchronizes itself
using a private object so that if this instance is used as
a monitor it will not interfere with the operation of the
message notifications between the communicating threads.
Method Detail |
---|
public void enqueue(java.lang.Object value)
value
- the object to be scheduled in the queuepublic java.lang.Object dequeue() throws java.lang.InterruptedException
java.lang.InterruptedException
- thrown if theres an interrupt
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |