< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/TimedWaitingThread.java

Print this page

 23 package nsk.monitoring.share.thread;
 24 
 25 import nsk.share.log.Log;
 26 import java.lang.management.ThreadInfo;
 27 import java.lang.management.MonitorInfo;
 28 import java.lang.management.LockInfo;
 29 import nsk.share.test.LocalRandom;
 30 import nsk.share.TestBug;
 31 
 32 /**
 33  * TimedWaitingThread is RecursiveMonitoringThread that is waiting on a lock.
 34  */
 35 public class TimedWaitingThread extends RecursiveMonitoringThread {
 36         private String lock = new String("a lock");
 37         private volatile boolean ready = false;
 38         private Object readyLock = new Object();
 39         private int count = LocalRandom.nextInt(100) + 1;
 40         private volatile int n = 0;
 41         private static final String[] expectedMethods = {
 42                 "java.lang.Object.wait",

 43                 "nsk.monitoring.share.thread.TimedWaitingThread.runInside"
 44         };
 45 
 46         public TimedWaitingThread(Log log, RunType recursionType, int maxDepth) {
 47                 super(log, recursionType, maxDepth);
 48         }
 49 
 50         public void checkThreadInfo(ThreadInfo info) {
 51                 super.checkThreadInfo(info);
 52                 verify(info.getThreadState() == Thread.State.TIMED_WAITING, "ThreadInfo.getThreadState() = " + info.getThreadState() + " != " + Thread.State.TIMED_WAITING);
 53                 //verify(info.getBlockedTime() == 0 || info.getBlockedTime() == -1, "ThreadInfo.getBlockedTime() == " + info.getBlockedTime());
 54                 //verify(info.getBlockedCount() == count, "ThreadInfo.getBlockedCount() = " + info.getBlockedCount() + " != " + count);
 55                 verify(info.getWaitedTime() == 0 || info.getWaitedTime() == -1, "ThreadInfo.getWaitedTime() == " + info.getWaitedTime());
 56                 verify(info.getWaitedCount() == count + 1, "ThreadInfo.getWaitedCount() = " + info.getWaitedCount() + " != " + (count + 1));
 57                 checkLockInfo(info.getLockInfo());
 58                 verify(info.getLockName().equals(info.getLockInfo().toString()), "ThreadInfo.getLockName() = " + info.getLockName() + " != ThreadInfo.getLockInfo().toString() = " + info.getLockInfo().toString());
 59                 verify(info.getLockOwnerId() == -1, "ThreadInfo.getLockOwnerId() = " + info.getLockOwnerId() + " != -1");
 60                 verify(info.getLockOwnerName() == null, "ThreadInfo.getLockOwnerName() = " + info.getLockOwnerName() + " != null");
 61                 checkMonitorInfo(info.getLockedMonitors(), null);
 62                 checkSynchronizers(info.getLockedSynchronizers(), null);

 23 package nsk.monitoring.share.thread;
 24 
 25 import nsk.share.log.Log;
 26 import java.lang.management.ThreadInfo;
 27 import java.lang.management.MonitorInfo;
 28 import java.lang.management.LockInfo;
 29 import nsk.share.test.LocalRandom;
 30 import nsk.share.TestBug;
 31 
 32 /**
 33  * TimedWaitingThread is RecursiveMonitoringThread that is waiting on a lock.
 34  */
 35 public class TimedWaitingThread extends RecursiveMonitoringThread {
 36         private String lock = new String("a lock");
 37         private volatile boolean ready = false;
 38         private Object readyLock = new Object();
 39         private int count = LocalRandom.nextInt(100) + 1;
 40         private volatile int n = 0;
 41         private static final String[] expectedMethods = {
 42                 "java.lang.Object.wait",
 43                 "java.lang.Object.wait0",
 44                 "nsk.monitoring.share.thread.TimedWaitingThread.runInside"
 45         };
 46 
 47         public TimedWaitingThread(Log log, RunType recursionType, int maxDepth) {
 48                 super(log, recursionType, maxDepth);
 49         }
 50 
 51         public void checkThreadInfo(ThreadInfo info) {
 52                 super.checkThreadInfo(info);
 53                 verify(info.getThreadState() == Thread.State.TIMED_WAITING, "ThreadInfo.getThreadState() = " + info.getThreadState() + " != " + Thread.State.TIMED_WAITING);
 54                 //verify(info.getBlockedTime() == 0 || info.getBlockedTime() == -1, "ThreadInfo.getBlockedTime() == " + info.getBlockedTime());
 55                 //verify(info.getBlockedCount() == count, "ThreadInfo.getBlockedCount() = " + info.getBlockedCount() + " != " + count);
 56                 verify(info.getWaitedTime() == 0 || info.getWaitedTime() == -1, "ThreadInfo.getWaitedTime() == " + info.getWaitedTime());
 57                 verify(info.getWaitedCount() == count + 1, "ThreadInfo.getWaitedCount() = " + info.getWaitedCount() + " != " + (count + 1));
 58                 checkLockInfo(info.getLockInfo());
 59                 verify(info.getLockName().equals(info.getLockInfo().toString()), "ThreadInfo.getLockName() = " + info.getLockName() + " != ThreadInfo.getLockInfo().toString() = " + info.getLockInfo().toString());
 60                 verify(info.getLockOwnerId() == -1, "ThreadInfo.getLockOwnerId() = " + info.getLockOwnerId() + " != -1");
 61                 verify(info.getLockOwnerName() == null, "ThreadInfo.getLockOwnerName() = " + info.getLockOwnerName() + " != null");
 62                 checkMonitorInfo(info.getLockedMonitors(), null);
 63                 checkSynchronizers(info.getLockedSynchronizers(), null);
< prev index next >