1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
7 /** Simple implementation of a blocking, counting semaphore. */
8 public class Semaphore {
12 public synchronized void dec() {
16 /** Decrement the counter, blocking if zero. */
17 public synchronized void block() {
21 } catch (InterruptedException e) {
22 } catch (Throwable e) {
23 if (Log.on) Log.info(this, "Exception in Semaphore.block(); this should never happen");
24 if (Log.on) Log.info(this, e);
30 /** Incremenet the counter. */
31 public synchronized void release() {