harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r565819 - /harmony/enhanced/drlvm/trunk/vm/tests/smoke/gc/ThreadSuspension.java
Date Tue, 14 Aug 2007 16:09:30 GMT
Author: gshimansky
Date: Tue Aug 14 09:09:29 2007
New Revision: 565819

URL: http://svn.apache.org/viewvc?view=rev&rev=565819
Log:
Applied patch from HARMONY-3962
[drlvm][test][smoke] Fix to gc.ThreadSuspension test


Modified:
    harmony/enhanced/drlvm/trunk/vm/tests/smoke/gc/ThreadSuspension.java

Modified: harmony/enhanced/drlvm/trunk/vm/tests/smoke/gc/ThreadSuspension.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/smoke/gc/ThreadSuspension.java?view=diff&rev=565819&r1=565818&r2=565819
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/smoke/gc/ThreadSuspension.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/smoke/gc/ThreadSuspension.java Tue Aug 14 09:09:29
2007
@@ -29,20 +29,25 @@
 public class ThreadSuspension implements Runnable {
 
     static boolean passed = false;
+    static boolean suspended2 = true;
+    static boolean suspended3 = true;
+    static Thread x1, x2, x3;
 
     public static void main (String[] args) {
-        Thread x1 = new Thread(new ThreadSuspension(1)); 
+        x1 = new Thread(new ThreadSuspension(1)); 
         x1.setDaemon(true); x1.start();
-        Thread x2 = new Thread(new ThreadSuspension(2)); 
+        x2 = new Thread(new ThreadSuspension(2)); 
         x2.setDaemon(true); x2.start();
-        Thread x3 = new Thread(new ThreadSuspension(3)); 
+        x3 = new Thread(new ThreadSuspension(3)); 
         x3.setDaemon(true); x3.start(); 
+        //wait for large timeout interval
         try { 
             synchronized(x1) {
-                x1.wait(3000);
+                x1.wait();
             } 
         } catch (Throwable e) {}
         if (passed) {
+			//VM successfully suspended the threads
             trace("PASS");
         } else {
             trace("FAIL");
@@ -59,10 +64,16 @@
                 try { Thread.sleep(1000); } catch (Throwable e) {}
                 trace("forcing gc after 1 s delay");
                 System.gc();
-                trace("gc completed");
-                passed = true;
-                synchronized (this) {
-                    notify();
+                if(suspended2 && suspended3)
+                {
+					//VM suspendeded both the threads
+					trace("gc completed");
+					passed = true;
+				}
+				else
+					passed = false;
+                synchronized (x1) {
+                    x1.notify();
                 }
                 break;
             case 2:
@@ -72,6 +83,7 @@
                     j = 1000 + j/(i+1);
                 }
                 trace("-- unsuspendable computation finished --");
+                suspended2 = false;
                 break;
             case 3:
                 trace("-- starting suspendable computation --");
@@ -79,6 +91,7 @@
                     Thread.yield();
                 }
                 trace("-- suspendable computation finished --");
+                suspended3 = false;
                 break;
         }
     }



Mime
View raw message