< prev index next >

test/hotspot/jtreg/serviceability/tmtools/jstack/WaitNotifyThreadTest.java

Print this page

 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @summary  Call Object.wait() method. Check that monitor information
 27  *           presented in the stack is correct. Call notifyAll method
 28  *           monitor info have to disappear from the stack.
 29  *           Repeats the same scenario calling interrupt() method
 30  * @modules java.base/jdk.internal.misc
 31  * @library /test/lib
 32  * @library ../share
 33  * @run main/othervm -XX:+UsePerfData WaitNotifyThreadTest
 34  */
 35 import common.ToolResults;
 36 import java.util.Iterator;
 37 import utils.*;
 38 
 39 public class WaitNotifyThreadTest {
 40 
 41     private Object monitor = new Object();
 42     private final String OBJECT = "a java.lang.Object";
 43     private final String OBJECT_WAIT = "java.lang.Object.wait0";
 44     private final String RUN_METHOD = "WaitNotifyThreadTest$WaitThread.run";
 45 
 46     interface Action {
 47         void doAction(Thread thread);
 48     }
 49 
 50     class ActionNotify implements Action {
 51 
 52         @Override
 53         public void doAction(Thread thread) {
 54             // Notify the waiting thread, so it stops waiting and sleeps
 55             synchronized (monitor) {
 56                 monitor.notifyAll();
 57             }
 58             // Wait until MyWaitingThread exits the monitor and sleeps
 59             while (thread.getState() != Thread.State.TIMED_WAITING) {}
 60         }
 61     }

 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @summary  Call Object.wait() method. Check that monitor information
 27  *           presented in the stack is correct. Call notifyAll method
 28  *           monitor info have to disappear from the stack.
 29  *           Repeats the same scenario calling interrupt() method
 30  * @modules java.base/jdk.internal.misc
 31  * @library /test/lib
 32  * @library ../share
 33  * @run main/othervm -XX:+UsePerfData WaitNotifyThreadTest
 34  */
 35 import common.ToolResults;
 36 import java.util.Iterator;
 37 import utils.*;
 38 
 39 public class WaitNotifyThreadTest {
 40 
 41     private Object monitor = new Object();;
 42     private final String OBJECT = "a java.lang.Object";
 43     private final String OBJECT_WAIT = "java.lang.Object.wait0";
 44     private final String RUN_METHOD = "WaitNotifyThreadTest$WaitThread.run";
 45 
 46     interface Action {
 47         void doAction(Thread thread);
 48     }
 49 
 50     class ActionNotify implements Action {
 51 
 52         @Override
 53         public void doAction(Thread thread) {
 54             // Notify the waiting thread, so it stops waiting and sleeps
 55             synchronized (monitor) {
 56                 monitor.notifyAll();
 57             }
 58             // Wait until MyWaitingThread exits the monitor and sleeps
 59             while (thread.getState() != Thread.State.TIMED_WAITING) {}
 60         }
 61     }
< prev index next >