2 * Simple semaphore implementation, from Doug Lea (public domain)
\r
4 * Copyright 2006,2007,2010 The SimGrid Team
\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 org.simgrid.msg;
\r
20 /******************************************************************/
\r
21 /* Simple semaphore implementation, from Doug Lea (public domain) */
\r
22 /******************************************************************/
\r
23 private int permits_;
\r
35 * @throws java.lang.InterruptedException
\r
37 public void acquire() throws InterruptedException {
\r
38 if (Thread.interrupted())
\r
39 throw new InterruptedException();
\r
41 synchronized(this) {
\r
43 while (permits_ <= 0)
\r
47 catch(InterruptedException ex) {
\r
57 public synchronized void release() {
\r