changeset 1258:fb97068670e6

6535104: TEST_BUG: FindDeadlocks.java fails intermittently. Summary: Retry a few times to check thread status before reporting failure Reviewed-by: swamyv
author mchung
date Tue, 26 May 2009 18:09:32 -0700
parents a7a38e606a7a
children 742b55c45a70
files test/java/lang/management/ThreadMXBean/SynchronizerDeadlock.java test/java/lang/management/ThreadMXBean/SynchronizerLockingThread.java
diffstat 2 files changed, 22 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/lang/management/ThreadMXBean/SynchronizerDeadlock.java	Tue May 26 18:07:14 2009 -0700
+++ b/test/java/lang/management/ThreadMXBean/SynchronizerDeadlock.java	Tue May 26 18:09:32 2009 -0700
@@ -83,11 +83,24 @@
 
     void waitUntilDeadlock() {
         barr.await();
-        // sleep a little while to wait until threads are blocked.
-        try {
-            Thread.sleep(100);
-        } catch (InterruptedException e) {
-            // ignore
+
+        for (int i=0; i < 100; i++) {
+            // sleep a little while to wait until threads are blocked.
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                // ignore
+            }
+            boolean retry = false;
+            for (Thread t: dThreads) {
+                if (t.getState() == Thread.State.RUNNABLE) {
+                    retry = true;
+                    break;
+                }
+            }
+            if (!retry) {
+                break;
+            }
         }
     }
 
--- a/test/java/lang/management/ThreadMXBean/SynchronizerLockingThread.java	Tue May 26 18:07:14 2009 -0700
+++ b/test/java/lang/management/ThreadMXBean/SynchronizerLockingThread.java	Tue May 26 18:09:32 2009 -0700
@@ -28,7 +28,7 @@
  *          monitors.
  * @author  Mandy Chung
  *
- * @build ThreadDump
+ * @build ThreadDump Utils
  */
 
 import java.lang.management.*;
@@ -63,6 +63,9 @@
                throw new RuntimeException(e);
            }
         }
+
+        Utils.waitForBlockWaitingState(t1);
+        Utils.waitForBlockWaitingState(t2);
     }
 
     static long[] getThreadIds() {