Add test for reentrant feature of the synchronized blocks
authorjzhou <jzhou>
Thu, 14 Oct 2010 18:06:29 +0000 (18:06 +0000)
committerjzhou <jzhou>
Thu, 14 Oct 2010 18:06:29 +0000 (18:06 +0000)
Robust/src/Tests/MGC/SynchonizedTest.java

index bb63fb183cd290bda5846f2d80ca2d61d56a27ad..9b5528bcfc12d082800ad9c8ea25481924db6ca2 100644 (file)
@@ -8,7 +8,6 @@ public class Counter{
 
   public synchronized void add(long value){
     this.count += value;
-    System.printString(" " + this.count + "\n");
   }
   
   public synchronized long getCounter() {
@@ -30,6 +29,7 @@ public class CounterThread extends Thread{
     for(int i=0; i<10; i++){
       System.printString(this.name);
       counter.add(i);
+      System.printString(" " + counter.getCounter() + "\n");
     }
   }
 }
@@ -46,4 +46,14 @@ public class SynchonizedTest {
     threadA.start();
     threadB.start(); 
   }
+  
+  /*public static void main(String[] args){
+    Counter counterA = new Counter();
+    Counter counterB = new Counter();
+    Thread  threadA = new CounterThread("A\n",counterA);
+    Thread  threadB = new CounterThread("B\n",counterB);
+
+    threadA.start();
+    threadB.start(); 
+  }*/
 }