📄 selectable.java
字号:
package concurrency.message;
class Selectable {
private boolean open = false;
private int ready = 0;
private Select inchoice = null;
private boolean guard_ = true;
void setSelect(Select s) {
inchoice = s;
}
synchronized void block() throws InterruptedException {
if (inchoice == null) {
setOpen();
while(ready==0) wait();
clearOpen();
}
}
synchronized void signal() {
if (inchoice == null) {
++ready;
if (open) notifyAll();
} else {
synchronized (inchoice) {
++ready;
if (open) inchoice.notifyAll();
}
}
}
boolean testReady() {
return ready>0;
}
synchronized void clearReady() {
--ready;
}
void setOpen() {
open=true;
}
void clearOpen() {
open=false;
}
public void guard(boolean g) {
guard_=g;
}
boolean testGuard(){
return guard_;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -