?? cubbyhole.java
字號:
public class CubbyHole {
private int contents;
private int available = 1;
public synchronized int get() {
while (available != 0) {
try {
wait();
} catch (InterruptedException e) { }
}
available = 1;
notifyAll();
return contents;
}
public synchronized void put(int value) {
while (available !=1) {
try {
wait();
} catch (InterruptedException e) { }
}
contents = value;
available = 2;
notifyAll();
}
public synchronized void add() {
while (available !=2) {
try {
wait();
} catch (InterruptedException e) { }
}
contents=contents+10;
available = 0;
notifyAll();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -