chopstick.java
来自「北大Java 语言程序设计 ppt课件及源码」· 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 + -
显示快捷键?