6512493: TEST_BUG: unexpected LockInfo failure in LockedSynchronizers.java

Retry a few times to check thread status before reporting failure

Reviewed-by: swamyv
This commit is contained in:
Mandy Chung 2009-05-26 18:07:14 -07:00
parent 354731edb5
commit dd2d72ea50
2 changed files with 20 additions and 5 deletions

View File

@ -66,6 +66,8 @@ public class LockingThread extends Thread {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
Utils.waitForBlockWaitingState(t1);
Utils.waitForBlockWaitingState(t2);
} }
static long[] getThreadIds() { static long[] getThreadIds() {
return new long[] {t1.getId(), t2.getId()}; return new long[] {t1.getId(), t2.getId()};

View File

@ -83,12 +83,25 @@ public class MonitorDeadlock {
void waitUntilDeadlock() { void waitUntilDeadlock() {
barr.await(); barr.await();
for (int i=0; i < 100; i++) {
// sleep a little while to wait until threads are blocked. // sleep a little while to wait until threads are blocked.
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException e) { } catch (InterruptedException e) {
// ignore // ignore
} }
boolean retry = false;
for (Thread t: dThreads) {
if (t.getState() == Thread.State.RUNNABLE) {
retry = true;
break;
}
}
if (!retry) {
break;
}
}
} }
private class DeadlockingThread extends Thread { private class DeadlockingThread extends Thread {