From e6e5ee9a3579c7f2bff92db77ade6bbb11c7b08e Mon Sep 17 00:00:00 2001 From: jzhou Date: Thu, 3 May 2012 17:31:29 +0000 Subject: [PATCH] Fix the thread safe problem --- Robust/src/ClassLibrary/MGC/gnu/Semaphore.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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()!"); -- 2.34.1