Fix the thread safe problem
authorjzhou <jzhou>
Thu, 3 May 2012 17:31:29 +0000 (17:31 +0000)
committerjzhou <jzhou>
Thu, 3 May 2012 17:31:29 +0000 (17:31 +0000)
Robust/src/ClassLibrary/MGC/gnu/Semaphore.java

index 29d36d9a39b2d774e3ea7c4c0ff8396dc9bf65f9..365384933d879f08d12b5382ee1cf0e2bc0fc1d9 100644 (file)
@@ -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
      */
      * @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)!");
         /*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
      */
      * @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()!");
         /*if (permits < 0) throw new IllegalArgumentException();
         sync.releaseShared(permits);*/
       //System.out.println("Unimplemented Semaphore.release()!");