chopstick.java
来自「初期JAVA学习非常有用的资料。帮助深入了解API。特别是Applet。」· Java 代码 · 共 19 行
JAVA
19 行
import java.awt.*;public class Chopstick { Philosopher owner = null; public synchronized void release(Philosopher phil) { if (phil == owner) owner = null; notify(); } public synchronized void grab(Philosopher phil) throws InterruptedException { while (owner != null) wait(); owner = phil; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?