Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting a list of running non-daemon threads in jvisualvm

I am troubleshooting a shutdown that is not as graceful as it should be, so I would like to get a list of running non-daemon threads in jvisualvm (or other) to hunt the culprit.

like image 673
Rom1 Avatar asked Jan 24 '12 09:01

Rom1


People also ask

How do I monitor JVM threads?

The simplest way to see the number of threads in Java is to use a graphical tool like Java VisualVM. Apart from the application threads, Java VisualVM also lists the GC or any other threads used by the application like JMX threads. Monitoring the number of threads is the most basic feature in Java VisualVM.

What is non-daemon thread?

Daemon threads are low priority threads which always run in background and user threads are high priority threads which always run in foreground. User Thread or Non-Daemon are designed to do specific or complex task where as daemon threads are used to perform supporting tasks.

How do I check my daemon threads?

you can check thread as daemon or user by using "isDaemon()" method.

What is non-daemon thread in Python?

The threads which are always going to run in the background that provides supports to main or non-daemon threads, those background executing threads are considered as Daemon Threads. The Daemon Thread does not block the main thread from exiting and continues to run in the background.


1 Answers

jstack dumps all threads, there is a text that would tell if it is daemon or not

( jvisualvm produces same output in 'ThreadDump'- See this link for more useful documentation

 "Reference Handler" daemon prio=10 tid=0x00a98400 nid=0x1ee8 in Object.wait() [0x00b6f000]
           java.lang.Thread.State: WAITING (on object monitor)
                at java.lang.Object.wait(Native Method)
                at java.lang.Object.wait(Object.java:485)
                at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
                - locked <0x19835fa0> (a java.lang.ref.Reference$Lock)
    
    "VM Thread" prio=10 tid=0x00a95800 nid=0x264 runnable
like image 98
Jayan Avatar answered Oct 28 '22 04:10

Jayan