semaphore.java
来自「将用户指定的数据保存成一个iso文件」· Java 代码 · 共 43 行
JAVA
43 行
/* * Semaphore.java * * Created on February 16, 2004, 1:54 PM */package jcdwriter.model;/** * * @author rmallappa */public class Semaphore { int excessSignals = 0; /** Creates a new instance of Semaphore */ public Semaphore() { } public synchronized void waitForSignal() { try { if (excessSignals > 0) {// System.out.println("Got signal without wait! Cool!"); } else {// System.out.println("Waiting."); wait(); } } catch (InterruptedException e) { } excessSignals = excessSignals - 1; notifyAll(); return; } public synchronized void signal() { excessSignals = excessSignals + 1;// System.out.println("Gog a signal."); notifyAll(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?