From d7b9eb0c77165f646d3c73ff36ae12e0da10ae73 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 3 Sep 2004 00:27:30 +0000 Subject: [PATCH] added ability to count to Semaphore class darcs-hash:20040903002730-5007d-1a8c33bb90720ccf2a955f27d432cb264fdd2273.gz --- src/org/ibex/util/Semaphore.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/org/ibex/util/Semaphore.java b/src/org/ibex/util/Semaphore.java index ad8376f..b37993c 100644 --- a/src/org/ibex/util/Semaphore.java +++ b/src/org/ibex/util/Semaphore.java @@ -12,9 +12,13 @@ public class Semaphore { private int val = 0; + public synchronized void dec() { + val--; + } + /** Decrement the counter, blocking if zero. */ public synchronized void block() { - while(val == 0) { + while(val <= 0) { try { wait(); } catch (InterruptedException e) { -- 1.7.10.4