当前位置: 首页>>代码示例>>Java>>正文


Java VirtualMachine.allThreads方法代码示例

本文整理汇总了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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:GetObjectLockCount.java

示例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.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:ProcessAttachDebugger.java

示例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.");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:Operator.java


注:本文中的com.sun.jdi.VirtualMachine.allThreads方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。