本文整理汇总了Java中com.sun.jdi.VirtualMachine.allThreads方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualMachine.allThreads方法的具体用法?Java VirtualMachine.allThreads怎么用?Java VirtualMachine.allThreads使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.VirtualMachine
的用法示例。
在下文中一共展示了VirtualMachine.allThreads方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLockRecursions
import com.sun.jdi.VirtualMachine; //导入方法依赖的package包/类
public static int getLockRecursions(VirtualMachine vm) {
List <ThreadReference> threads = vm.allThreads();
for (ThreadReference thread : threads) {
if (thread.name().equals("main")) {
System.out.println("Found main thread.");
try{
StackFrame frame = thread.frame(3);
return frame.thisObject().entryCount();
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("Main thread not found!");
}
return -1;
}
示例2: main
import com.sun.jdi.VirtualMachine; //导入方法依赖的package包/类
public static void main(String main_args[]) throws Exception {
String pid = main_args[0];
// find ProcessAttachingConnector
List<AttachingConnector> l =
Bootstrap.virtualMachineManager().attachingConnectors();
AttachingConnector ac = null;
for (AttachingConnector c: l) {
if (c.name().equals("com.sun.jdi.ProcessAttach")) {
ac = c;
break;
}
}
if (ac == null) {
throw new RuntimeException("Unable to locate ProcessAttachingConnector");
}
Map<String,Connector.Argument> args = ac.defaultArguments();
Connector.StringArgument arg = (Connector.StringArgument)args.get("pid");
arg.setValue(pid);
System.out.println("Debugger is attaching to: " + pid + " ...");
VirtualMachine vm = ac.attach(args);
System.out.println("Attached! Now listing threads ...");
// list all threads
for (ThreadReference thr: vm.allThreads()) {
System.out.println(thr);
}
System.out.println("Debugger done.");
}
示例3: dumpThreadsStatus
import com.sun.jdi.VirtualMachine; //导入方法依赖的package包/类
public static void dumpThreadsStatus(VirtualMachine vm, Level l) {
logger.log(l, "DUMP of threads:\n");
List<ThreadReference> allThreads = vm.allThreads();
for (ThreadReference t : allThreads) {
logger.log(l, " "+t+" "+JPDAThreadImpl.getThreadStateLog(t));
}
logger.log(l, "DUMP DONE.");
}