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
11 \rpackage simgrid.msg;
12 \r\rpublic class Sem {
14 /******************************************************************/
\r
15 /* Simple semaphore implementation, from Doug Lea (public domain) */
\r
16 /******************************************************************/
\r
18 \r\rpublic Sem(int i) {
20 \r}
\r\rpublic void acquire() throws InterruptedException {
21 \r\rif (Thread.interrupted())
22 \rthrow new InterruptedException();
23 \r\rsynchronized(this) {
25 \rwhile (permits_ <= 0)
29 \rcatch(InterruptedException ex) {
35 \r\rpublic synchronized void release() {