Search code examples
multithreadingperformancejbossjmxvisualvm

JBoss Threads - JMX vs Java Visual VM - reporting different results - Why?


When i use Java VisualVM to monitor my JBoss Application.
It shows
Live Threads as: 155
Daemon Threads as: 135

When i use JMX Web Console of JBoss.
It shows
Current Busy Threads as: 40
Current Thread Count as: 60

Why is there so much discrepancy between what Java Visual VM is reporting and what JMX Web Console shows. (How is Live Threads different from Busy Threads)


Solution

  • A live thread is one that exists and is not Terminated. (See Thread.State) A busy thread is one that is actually working or, more precisely, Runnable.

    JBoss's Web Console tends to report fewer threads because it is very non-invasive. In other words, it does not have to spawn additional threads just to render you a web page. It's already running a web server and it already allocated threads to handle web requests before you went into JMX Console.

    Visual VM on the other hand, starts up several threads to support the JMX remoting (usually RMI) which comes with a little extra baggage. You might see extra threads like:

    RMI TCP Connection(867)
    RMI TCP Connection(868)
    RMI TCP Connection(869)
    JMX server connection timeout
    

    Having said that, the discrepancy you are reporting is way out of line and makes me think that you're not looking at the same JVM.

    The JMX Console is obvious :), so I would guess your Visual VM is connected elsewhere. See if you can correlate similar thread name (using the MBean jboss.system:type=ServerInfo listThreadDump operation), or browse the MBeans in Visual VM and inspect the JBoss MBeans. These mbeans are good ones to look at because they indicate a binding to a socket so they could not have the same values if they were not the same JVM process:

    jboss.web:name=HttpRequest1,type=RequestProcessor,worker=http-0.0.0.0-18080
    

    Of course, the other thing would be that if you start VisualVM first, have it running and then go to JMX Console and don't see as many threads, you're definitely in a different VM.

    Cheers.

    //Nicholas