4 * Copyright 2006,2007 Martin Quinson, Malek Cherier
\r
5 * All right reserved.
\r
7 * This program is free software; you can redistribute
\r
8 * it and/or modify it under the terms of the license
\r
9 *(GNU LGPL) which comes with this package.
\r
12 package simgrid.msg;
\r
16 /******************************************************************/
\r
17 /* Simple semaphore implementation, from Doug Lea (public domain) */
\r
18 /******************************************************************/
\r
19 private int permits_;
\r
25 public void acquire() throws InterruptedException {
\r
27 if (Thread.interrupted())
\r
28 throw new InterruptedException();
\r
30 synchronized(this) {
\r
33 while (permits_ <= 0)
\r
38 catch (InterruptedException ex) {
\r
45 public synchronized void release() {
\r