📄 control.java
字号:
package waitANDnotify;
public class Control {
int n;
boolean valueSet;
synchronized int get(){
if(valueSet){
try{
wait();
}catch (InterruptedException e){
System.out.println("InterRuption occur.");
}
}
System.out.println("Got: "+n);
valueSet=false;
notify();
return n;
}
synchronized void put(int n){
if(valueSet){
try{
wait();
}catch(InterruptedException e){
System.out.println("InterRuption occur.");
}
}
this.n=n;
System.out.println("Put: "+n);
valueSet=false;
notify();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -