public interface MessageQueue
A two-way unbounded-length message queue useful for communication between threads. Messages written on one side become readable on the other in first-in, first-out order. This is an interface to one of two "sides" of an underlying backend, for example, the MessageQueueBackend.
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
readMessage()
This blocks until a message is available.
|
java.lang.Object |
readMessageWithTimeout(long millis)
This blocks for up to
millis milliseconds until a
message is available. |
void |
writeMessage(java.lang.Object obj)
Write a message to the queue
|
java.lang.Object readMessage()
java.lang.Object readMessageWithTimeout(long millis)
millis
milliseconds until a
message is available. If no message becomes available within
this time period, or the thread is interrupted during the wait,
returns null. (This implies that passing the value null back and
forth is not distinguishable with this method.) Passing a value
of 0 for the millis
argument causes this method to
return without blocking. The millis argument must be greater
than or equal to zero.void writeMessage(java.lang.Object obj)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.