2 * Simple semaphore implementation, from Doug Lea (public domain)
\r
4 * Copyright 2006,2007,2010,2011 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
15 /******************************************************************/
\r
16 /* Simple semaphore implementation, from Doug Lea (public domain) */
\r
17 /******************************************************************/
\r
18 private int permits_;
\r
30 * @throws java.lang.InterruptedException
\r
32 public void acquire() throws InterruptedException {
\r
33 if (Thread.interrupted())
\r
34 throw new InterruptedException();
\r
36 synchronized(this) {
\r
38 while (permits_ <= 0)
\r
42 catch(InterruptedException ex) {
\r
52 public synchronized void release() {
\r