⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chopstick.java

📁 北大Java 语言程序设计 ppt课件及源码
💻 JAVA
字号:
/* * This class requires no changes from the 1.0 version.  * It's kept here so the rest of the example can compile. */public class Chopstick {    Thread holder = null;    public synchronized void grab() throws InterruptedException {        while (holder != null)            wait();        holder = Thread.currentThread();    }    public synchronized void release() {        holder = null;        notify();    }    public synchronized void releaseIfMine() {        if (holder == Thread.currentThread())            holder = null;        notify();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -