From: jzhou Date: Thu, 3 May 2012 17:31:29 +0000 (+0000) Subject: Fix the thread safe problem X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=e6e5ee9a3579c7f2bff92db77ade6bbb11c7b08e;p=IRC.git Fix the thread safe problem --- diff --git a/Robust/src/ClassLibrary/MGC/gnu/Semaphore.java b/Robust/src/ClassLibrary/MGC/gnu/Semaphore.java index 29d36d9a..36538493 100644 --- a/Robust/src/ClassLibrary/MGC/gnu/Semaphore.java +++ b/Robust/src/ClassLibrary/MGC/gnu/Semaphore.java @@ -447,7 +447,7 @@ public class Semaphore implements /*java.io.*/Serializable { * @throws InterruptedException if the current thread is interrupted * @throws IllegalArgumentException if {@code permits} is negative */ - public void acquire(int permits) throws InterruptedException { + public synchronized void acquire(int permits) throws InterruptedException { /*if (permits < 0) throw new IllegalArgumentException(); sync.acquireSharedInterruptibly(permits);*/ //System.out.println("Unimplemented Semaphore.acquire(int)!"); @@ -594,7 +594,7 @@ public class Semaphore implements /*java.io.*/Serializable { * @param permits the number of permits to release * @throws IllegalArgumentException if {@code permits} is negative */ - public void release(int permits) { + public synchronized void release(int permits) { /*if (permits < 0) throw new IllegalArgumentException(); sync.releaseShared(permits);*/ //System.out.println("Unimplemented Semaphore.release()!");