// Get list of Java threads that have called Object.wait on the specified monitor. public List getWaitingThreads(ObjectMonitor monitor) { List pendingThreads = new ArrayList(); for (JavaThread thread = first(); thread != null; thread = thread.next()) { ObjectMonitor waiting = thread.getCurrentWaitingMonitor(); if (monitor.equals(waiting)) { pendingThreads.add(thread); } } return pendingThreads; }
// refer to Threads::get_pending_threads // Get list of Java threads that are waiting to enter the specified monitor. public List getPendingThreads(ObjectMonitor monitor) { List pendingThreads = new ArrayList(); for (JavaThread thread = first(); thread != null; thread = thread.next()) { if (thread.isCompilerThread() || thread.isCodeCacheSweeperThread()) { continue; } ObjectMonitor pending = thread.getCurrentPendingMonitor(); if (monitor.equals(pending)) { pendingThreads.add(thread); } } return pendingThreads; }