Print thread dump for a single thread

We had an issue where a single thread was using all the CPU. We wanted to check it at the command line while troubleshooting. We used what is below…

[atg@CMHLDECOMAP01 ~]$ jstack 3000 | awk '{if ($1 == "\"Thread-9\"") {i = 1;print $0} else if (i == 1 && $0 != "") {print $0} else if (i == 1 && $0 == "") {exit}}'
"Thread-9" daemon prio=10 tid=0x000000000c849800 nid=0xbd7 runnable [0x0000000041595000]
   java.lang.Thread.State: RUNNABLE
        at org.apache.log4j.Category.getEffectiveLevel(Category.java:439)
        at org.apache.log4j.Category.isDebugEnabled(Category.java:733)
        at com.arjuna.common.internal.util.logging.jakarta.Log4JLogger.isDebugEnabled(Log4JLogger.java:317)
        at com.arjuna.common.internal.util.logging.jakarta.JakartaRelevelingLogger.isDebugEnabled(JakartaRelevelingLogger.java:73)
        at com.arjuna.common.internal.util.logging.LogNoi18nImpl.isDebugEnabled(LogNoi18nImpl.java:108)
        at com.arjuna.ats.arjuna.coordinator.TransactionReaper.check(TransactionReaper.java:169)
        at com.arjuna.ats.internal.arjuna.coordinator.ReaperThread.run(ReaperThread.java:122)
[atg@CMHLDECOMAP01 ~]$

This will print the call stack of that given thread, and that given thread only.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.