semaforo.java
来自「一个agent 工具包,可以开发移动设备应用,考虑了安全措施」· Java 代码 · 共 28 行
JAVA
28 行
package SOMA.utility;
//import debug.System;
public class Semaforo {
private boolean available=true;
public synchronized void set() {
while(available==false) {
try {
wait();
} catch(InterruptedException e) {}
}
available=false;
notifyAll();
}
public synchronized void unset() {
while(available==true) {
try {
wait();
} catch(InterruptedException e) {}
}
available=true;
notifyAll();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?