changeset 315:1558a1741344

Generators: make sure interrupt tests start threads before signalling.
author shade
date Mon, 05 Sep 2016 21:19:51 +0300
parents b0c5e26af669
children 5938d81bff44
files jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java	Wed Aug 10 23:52:33 2016 +0300
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java	Mon Sep 05 21:19:51 2016 +0300
@@ -728,6 +728,7 @@
         pw.println("            Thread t1 = new Thread(new Runnable() {");
         pw.println("                public void run() {");
         pw.println("                    try {");
+        pw.println("                        holder.started = true;");
 
         if (info.getTest().equals(info.getState())) {
             emitMethodTermination(pw, actor, "                        state." + actor.getSimpleName(), "state");
@@ -743,10 +744,12 @@
         pw.println("            });");
         pw.println("            t1.start();");
         pw.println();
-        pw.println("            try {");
-        pw.println("                TimeUnit.MILLISECONDS.sleep(10);");
-        pw.println("            } catch (InterruptedException e) {");
-        pw.println("                // do nothing");
+        pw.println("            while (!holder.started) {");
+        pw.println("                try {");
+        pw.println("                    TimeUnit.MILLISECONDS.sleep(1);");
+        pw.println("                } catch (InterruptedException e) {");
+        pw.println("                    // do nothing");
+        pw.println("                }");
         pw.println("            }");
         pw.println();
         pw.println("            try {");
@@ -781,6 +784,7 @@
         pw.println("    }");
         pw.println();
         pw.println("    private static class Holder {");
+        pw.println("        volatile boolean started;");
         pw.println("        volatile boolean terminated;");
         pw.println("        volatile boolean error;");
         pw.println("    }");