【问题标题】:Is it possible to find the creation time of a thread using thread dump?是否可以使用线程转储找到线程的创建时间?
【发布时间】:2017-11-03 10:28:04
【问题描述】:

我使用jmap -dump:format=b,file=<file.dump> <PID> 命令生成JVM 实例的线程转储。我只是想知道是否可以使用生成的线程转储找到在 JVM 实例中运行的线程的创建时间。

【问题讨论】:

    标签: multithreading jvm thread-dump jmap eclipse-memory-analyzer


    【解决方案1】:

    这是堆转储,而不是线程转储。堆转储中没有关于线程创建时间的信息。但是,您可以从线程转储中找到它,如下所述。

    1. 使用jstack <PID>转储线程

    2. 找到您感兴趣的话题的nid

      "Thread-7" #30 daemon prio=5 os_prio=0 tid=0x00002aaac9688800 nid=0x6945 runnable [0x00000000429c5000]
                                                                        ^^^^^^
         java.lang.Thread.State: RUNNABLE
              at sun.nio.ch.EPoll.epollWait(Native Method)
              at sun.nio.ch.EPollPort$EventHandlerTask.poll(EPollPort.java:194)
              at sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:268)
              at java.lang.Thread.run(Thread.java:745)
      
    3. 转换为十进制:TID = 0x6945 = 26949

    4. 使用ps -Lo tid,lstart <PID> | grep <TID>获取开始时间

      26949 Tue May 30 19:16:29 2017
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多