algorithm_1.java
来自「other example of how sincronize process」· Java 代码 · 共 23 行
JAVA
23 行
public class Algorithm_1 extends MutualExclusion {
private volatile int turno;
public Algorithm_1(){
turno = TURN_0;
}
@Override
public void enteringCriticalSection(int t) {
// TODO Auto-generated method stub
while (turno != t)
Thread.yield();
}
@Override
public void leavingCriticalSection(int t) {
// TODO Auto-generated method stub
turno = 1 - t;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?