Java Thread monitoring. How to find out non daemon live threads?
Asked Answered
C

2

15

I see in JConsole that I still have 2 non daemon threads but I can't find out which exactly (total number of thread is beyond 30).
Visual VM doesn't provide such information.

Collettecolletti answered 16/12, 2011 at 16:20 Comment(0)
M
22

Run:

$ jstack PID | grep tid= | grep -v daemon

This will dump all the thread of a given Java PID, filter lines with thread names and filter out non-daemon ones.

Remove -v to print daemon threads only.

Madson answered 16/12, 2011 at 16:26 Comment(2)
unfortunately leaves a few odd threads in there, like GC threads, but close enough! :)Albie
A tip for future readers: you can find jstack in your JDK's bin folderIrremediable
B
2

Take a thread dump in VisualVM. Daemon threads have the word 'daemon' next to the thread name.

"Default RequestProcessor" daemon prio=1 tid=101e58000 nid=0x124d86000 runnable [124d85000]
Brig answered 17/12, 2011 at 15:19 Comment(1)
i dont see this in visualvm 1.33 on linux. which window do you refer to?Ohmage

© 2022 - 2024 — McMap. All rights reserved.