//@author: j.n.magee 11/11/96 //adapted by mh, 02/04/03 /********************************************************/ // // The Semaphore Class // up() is the V operation // down() is the P operation // public class BinSemaphore { private boolean value; public BinSemaphore (boolean initial) { /* if (initial<0) { System.exit(1); // out of range error } else { */ value = initial; /* } // if */ } // Semaphore synchronized public void up() { value = true; notify(); // notifyAll() ? } // up synchronized public void down() { try { while (!value) { wait(); } // end while value = false; } catch(InterruptedException e){} } // down } // class BinSemaphore