added ability to count to Semaphore class
[org.ibex.util.git] / src / org / ibex / util / Semaphore.java
index ad8376f..b37993c 100644 (file)
@@ -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) {