?? semaphore.java
字號:
/* * 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(); }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -