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
11 \rpackage simgrid.msg;
12 \r\rpublic class Sem {
\r
13 /******************************************************************/
\r
14 /* Simple semaphore implementation, from Doug Lea (public domain) */
\r
15 /******************************************************************/
\r
17 \r public Sem(int i) {
\r permits_ = i;
\r }
\r\r public void acquire() throws InterruptedException {
18 if (Thread.interrupted())
19 throw new InterruptedException();
20 \r synchronized(this) {
26 catch(InterruptedException ex) {
32 \r public synchronized void release() {