< prev index next >

test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java

Print this page
rev 47694 : imported patch 8190703-testsystemgc-timeout
rev 47695 : [mq]: 8190703-ashipilev-review2

@@ -88,19 +88,18 @@
 
 class SystemGCTask extends Exitable implements Runnable {
     private long delayMS;
 
     SystemGCTask(long delayMS) {
-System.err.println("SystemGCTask with delay " + delayMS);
         this.delayMS = delayMS;
     }
 
     @Override
     public void run() {
         while (!shouldExit()) {
             System.gc();
-            ThreadUtils.sleep(delayMS * 10);
+            ThreadUtils.sleep(delayMS);
         }
     }
 }
 
 public class TestSystemGC {

@@ -163,12 +162,11 @@
             task.exit();
         }
     }
 
     private static void runAllPhases() {
-        int i = 0;
-        while (i < 4 && System.currentTimeMillis() < endTime) {
+        for (int i = 0; i < 4 && System.currentTimeMillis() < endTime; i++) {
             SystemGCTask gcTask =
                 (i % 2 == 1) ? createSystemGCTask(numGroups / 3) : null;
             ShortLivedAllocationTask shortTask =
                 (i == 1 || i == 3) ?  new ShortLivedAllocationTask() : null;
             LongLivedAllocationTask longTask =

@@ -183,20 +181,20 @@
             exitTask(gcTask);
             exitTask(shortTask);
             exitTask(longTask);
 
             ThreadUtils.sleep(1000);
-            i++;
         }
     }
 
-    public static void main(String[] args) {
-        if (args.length > 0) {
+    public static void main(String[] args) throws Exception {
+        if (args.length == 0) {
+            throw new IllegalArgumentException("Must specify timeout in seconds as first argument");
+        }
             int timeout = Integer.parseInt(args[0]) * 1000;
             System.out.println("Running with timeout of " + timeout + "ms");
             endTime = System.currentTimeMillis() + timeout;
-        }
         // First allocate the long lived objects and then run all phases.
         populateLongLived();
         runAllPhases();
     }
 }
< prev index next >