本文整理汇总了Java中org.netbeans.api.debugger.jpda.JPDAThread.getOwnedMonitors方法的典型用法代码示例。如果您正苦于以下问题:Java JPDAThread.getOwnedMonitors方法的具体用法?Java JPDAThread.getOwnedMonitors怎么用?Java JPDAThread.getOwnedMonitors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.debugger.jpda.JPDAThread
的用法示例。
在下文中一共展示了JPDAThread.getOwnedMonitors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildGraph
import org.netbeans.api.debugger.jpda.JPDAThread; //导入方法依赖的package包/类
private void buildGraph(Collection<JPDAThread> threads) {
monitorToNode = new HashMap<Long, Node>();
for (JPDAThread thread : threads) {
if (thread.getState() == JPDAThread.STATE_ZOMBIE) {
continue;
}
ObjectVariable contendedMonitor = thread.getContendedMonitor();
ObjectVariable[] ownedMonitors = thread.getOwnedMonitors();
if (contendedMonitor != null && (((JDIVariable) contendedMonitor).getJDIValue() instanceof ThreadReference)) {
ownedMonitors = checkForThreadJoin(thread, ownedMonitors);
}
if (contendedMonitor == null || ownedMonitors.length == 0) {
continue;
} // if
Node contNode = monitorToNode.get(contendedMonitor.getUniqueID());
if (contNode == null) {
contNode = new Node(null, contendedMonitor);
monitorToNode.put(contendedMonitor.getUniqueID(), contNode);
}
for (int x = 0; x < ownedMonitors.length; x++) {
Node node = monitorToNode.get(ownedMonitors[x].getUniqueID());
if (node == null) {
node = new Node(thread, ownedMonitors[x]);
monitorToNode.put(ownedMonitors[x].getUniqueID(), node);
} else if (node.thread == null) {
node.thread = thread;
} else {
continue;
}
node.setOutgoing(contNode);
contNode.addIncomming(node);
} // for
} // for
}
示例2: getContendedMonitorAndOwner
import org.netbeans.api.debugger.jpda.JPDAThread; //导入方法依赖的package包/类
@Override
public MonitorInfo getContendedMonitorAndOwner() {
ObjectVariable monitor = getContendedMonitor();
if (monitor == null) return null;
// Search for the owner:
MonitorInfo monitorInfo = null;
JPDAThread thread = null;
List<JPDAThread> threads = debugger.getThreadsCollector().getAllThreads();
for (JPDAThread t : threads) {
if (this == t) continue;
ObjectVariable[] ms = t.getOwnedMonitors();
for (ObjectVariable m : ms) {
if (monitor.equals(m)) {
thread = t;
List<MonitorInfo> mf = t.getOwnedMonitorsAndFrames();
for (MonitorInfo mi : mf) {
if (monitor.equals(mi.getMonitor())) {
monitorInfo = mi;
break;
}
}
break;
}
}
if (thread != null) {
break;
}
}
if (monitorInfo != null) {
return monitorInfo;
}
return new MonitorInfoImpl(thread, null, monitor);
}