channel.java
来自「演示win32的socket 通讯 八皇后的改进算法 并发Concurren」· Java 代码 · 共 33 行
JAVA
33 行
/*
@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 + =
减小字号Ctrl + -
显示快捷键?