1 // Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
4 /** Simple implementation of a blocking, counting semaphore. */
5 public class Semaphore {
9 public Semaphore() { };
11 /** Decrement the counter, blocking if zero. */
12 public synchronized void block() {
16 } catch (InterruptedException e) {
17 } catch (Throwable e) {
18 if (Log.on) Log.log(this, "Exception in Semaphore.block(); this should never happen");
19 if (Log.on) Log.log(this, e);
25 /** Incremenet the counter. */
26 public synchronized void release() {