EDAF85-labs/wash/src/actor/ActorThread.java

25 lines
879 B
Java
Raw Normal View History

2024-06-10 10:53:11 +02:00
package actor;
public abstract class ActorThread<M> extends Thread {
// TODO: one suitable attribute here
/** Called by another thread, to send a message to this thread. */
public void send(M message) {
// TODO: implement this method (one or a few lines)
}
/** Returns the first message in the queue, or blocks if none available. */
protected M receive() throws InterruptedException {
// TODO: implement this method (one or a few lines)
return null;
}
/** Returns the first message in the queue, or blocks up to 'timeout'
milliseconds if none available. Returns null if no message is obtained
within 'timeout' milliseconds. */
protected M receiveWithTimeout(long timeout) throws InterruptedException {
// TODO: implement this method (one or a few lines)
return null;
}
}