mirror of
https://github.com/corda/corda.git
synced 2025-01-19 11:16:54 +00:00
use wait/notifyAll too avoid starvation in Trace test
Thread.yield is not enough to ensure that the tracing thread does not starve the test thread on some QEMU VMs, so we use wait/notifyAll to make sure both threads have opportunities to run and the test actually finishes.
This commit is contained in:
parent
a4c4d54cdd
commit
944e223335
@ -67,10 +67,16 @@ public class Trace implements Runnable {
|
||||
if (i % 100 == 0) {
|
||||
System.out.print("r");
|
||||
System.out.flush();
|
||||
synchronized (this) {
|
||||
notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
alive = false;
|
||||
synchronized (this) {
|
||||
alive = false;
|
||||
notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +94,7 @@ public class Trace implements Runnable {
|
||||
++ count;
|
||||
|
||||
if (count % 100 == 0) {
|
||||
Thread.yield();
|
||||
trace.wait();
|
||||
System.out.print("t");
|
||||
System.out.flush();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user