📄 channel.java
字号:
/*
@author j.n.magee 20/11/96
*/
package concurrency.message;
import java.awt.*;
import java.util.*;
import java.applet.*;
/* ********************CHANNEL**************************** */
// The definition of channel assumes that there is exactly one
// sender and one receiver.
public class Channel extends Selectable{
Object chan_ = null;
public synchronized void send(Object v) throws InterruptedException {
chan_ = v;
signal();
while (chan_ != null) wait();
}
public synchronized Object receive() throws InterruptedException {
block();
clearReady();
Object tmp = chan_; chan_ = null;
notifyAll(); //should be notify()
return(tmp);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -