< prev index next >

test/jdk/java/lang/Thread/virtual/stress/TimedWaitALot.java

Print this page
@@ -92,21 +92,24 @@
                  // 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) {
+                     executor.submit(() -> {
+                         if (ThreadLocalRandom.current().nextBoolean()) {
+                             synchronized (lock) {
+                                 sleepLessThan(timeout);
+                                 lock.notifyAll();
+                             }
+                         } else {
                              sleepLessThan(timeout);
-                             lock.notifyAll();
-                         }
-                     } else {
-                         sleepLessThan(timeout);
-                         synchronized (lock) {
-                             lock.notifyAll();
+                             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 >