UnahD
UnahD

Reputation: 877

Is it possible to find the creation time of a thread using thread dump?

I use jmap -dump:format=b,file=<file.dump> <PID> command to generate thread dump of a JVM instance. I just want to know if it's possible to find the time of creation of a thread running in the JVM instance, using the thread dump generated.

Upvotes: 1

Views: 2176

Answers (1)

apangin
apangin

Reputation: 98630

This is a heap dump, not a thread dump. There is no info about thread creation time in a heap dump. However, you can find it from a thread dump as described below.

  1. Dump threads using jstack <PID>

  2. Find nid of the thread you are interested in:

    "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. Convert it to decimal: TID = 0x6945 = 26949

  4. Get the start time using ps -Lo tid,lstart <PID> | grep <TID>

    26949 Tue May 30 19:16:29 2017
    

Upvotes: 4

Related Questions