1 // Copyright (C) 2003 Adam Megacz <adam@ibex.org> all rights reserved.
3 // You may modify, copy, and redistribute this code under the terms of
4 // the GNU Library Public License version 2.1, with the exception of
5 // the portion of clause 6a after the semicolon (aka the "obnoxious
10 /** Simple implementation of a blocking, counting semaphore. */
11 public class Semaphore {
15 /** Decrement the counter, blocking if zero. */
16 public synchronized void block() {
20 } catch (InterruptedException e) {
21 } catch (Throwable e) {
22 if (Log.on) Log.info(this, "Exception in Semaphore.block(); this should never happen");
23 if (Log.on) Log.info(this, e);
29 /** Incremenet the counter. */
30 public synchronized void release() {