public class Message
extends java.lang.Object
Constructor and Description |
---|
Message(java.lang.String content)
Constructor
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getContent()
Accessor for the content of this message
|
java.lang.Thread |
getSender()
Accessor for the sender of this message
|
static Message |
receive()
Receive a message.
|
void |
reply(java.lang.String replyContent)
Reply to the sender of this message.
|
void |
send(java.lang.Thread destination)
Send this message to another thread.
|
Message |
sendAwaitReply(java.lang.Thread destination)
Send this message to another thread, and wait for a reply.
|
java.lang.String |
toString()
Construct a string representation of this message
|
public Message(java.lang.String content)
content
- the content of the messagepublic void send(java.lang.Thread destination) throws java.lang.IllegalArgumentException
destination
- the thread to send this message tojava.lang.IllegalArgumentException
- if a thread attempts to send a
a message to itselfpublic Message sendAwaitReply(java.lang.Thread destination) throws java.lang.IllegalArgumentException
destination
- the thread to send this message tojava.lang.IllegalArgumentException
- if a thread attempts to send a
a message to itselfpublic static Message receive()
public void reply(java.lang.String replyContent)
replyContent
- the content of the replypublic java.lang.Thread getSender()
public java.lang.String getContent()
public java.lang.String toString()
toString
in class java.lang.Object