|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nachos.threads.Communicator
public class Communicator
A communicator allows threads to synchronously exchange 32-bit messages. Multiple threads can be waiting to speak, and multiple threads can be waiting to listen. But there should never be a time when both a speaker and a listener are waiting, because the two threads can be paired off at this point.
Constructor Summary | |
---|---|
Communicator()
Allocate a new communicator. |
Method Summary | |
---|---|
int |
listen()
Wait for a thread to speak through this communicator, and then return the word that thread passed to speak(). |
void |
speak(int word)
Wait for a thread to listen through this communicator, and then transfer word to the listener. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Communicator()
Method Detail |
---|
public void speak(int word)
Does not return until this thread is paired up with a listening thread. Exactly one listener should receive word.
word
- the integer to transfer.public int listen()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |