X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/30769c28f7021367f7d7f54e868dde6c2c17c050..94fb6e860980b4201d9aa7995e2f8648ed81ee8e:/org/simgrid/msg/Sem.java diff --git a/org/simgrid/msg/Sem.java b/org/simgrid/msg/Sem.java index 84ab9f25ef..e034d1a67b 100644 --- a/org/simgrid/msg/Sem.java +++ b/org/simgrid/msg/Sem.java @@ -1,35 +1,56 @@ /* * Simple semaphore implementation, from Doug Lea (public domain) * - * Copyright 2006,2007,2010 The SimGrid Team + * Copyright 2006,2007,2010,2011 The SimGrid Team * All right reserved. * * This program is free software; you can redistribute * it and/or modify it under the terms of the license *(GNU LGPL) which comes with this package. */ - package org.simgrid.msg; - public class Sem { + +package org.simgrid.msg; + +public class Sem { /******************************************************************/ /* Simple semaphore implementation, from Doug Lea (public domain) */ /******************************************************************/ - private int permits_; - public Sem(int i) { permits_ = i; } public void acquire() throws InterruptedException { - if (Thread.interrupted()) - throw new InterruptedException(); - synchronized(this) { - try { - while (permits_ <= 0) - wait(); - --permits_; - } - catch(InterruptedException ex) { - notify(); - throw ex; - } - } - } - public synchronized void release() { - ++(this.permits_); - notify(); - } } + private int permits_; + + /** + * + * @param i + */ + public Sem(int i) { + permits_ = i; + } + + /** + * + * @throws java.lang.InterruptedException + */ + public void acquire() throws InterruptedException { + if (Thread.interrupted()) + throw new InterruptedException(); + + synchronized(this) { + try { + while (permits_ <= 0) + wait(); + --permits_; + } + catch(InterruptedException ex) { + notify(); + throw ex; + } + } + } + + /** + * + */ + public synchronized void release() { + ++(this.permits_); + notify(); + } +}