< prev index next > test/jdk/java/lang/Thread/virtual/stress/TimedWaitALot.java
Print this page
// wait for thread to start
Thread thread = queue.take();
// start thread to Object.notifyAll at around time that the timeout expires
if (notify) {
! if (ThreadLocalRandom.current().nextBoolean()) {
! synchronized (lock) {
sleepLessThan(timeout);
! lock.notifyAll();
! }
! } else {
- sleepLessThan(timeout);
- synchronized (lock) {
- lock.notifyAll();
}
! }
}
// start thread to interrupt first thread at around time that the timeout expires
if (interrupt) {
executor.submit(() -> {
// wait for thread to start
Thread thread = queue.take();
// start thread to Object.notifyAll at around time that the timeout expires
if (notify) {
! executor.submit(() -> {
! if (ThreadLocalRandom.current().nextBoolean()) {
+ synchronized (lock) {
+ sleepLessThan(timeout);
+ lock.notifyAll();
+ }
+ } else {
sleepLessThan(timeout);
! synchronized (lock) {
! lock.notifyAll();
! }
}
! return null;
+ });
}
// start thread to interrupt first thread at around time that the timeout expires
if (interrupt) {
executor.submit(() -> {
< prev index next >