Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java JVM profiling, thread status - what does "Monitor" status mean?

enter image description here

I use visualVM connect a multi thread Java application, thread has 4 status, namely running, sleeping, wait, Monitor. What does this Monitoring status mean? What's the difference between wait and Monitor?

like image 617
user84592 Avatar asked Jul 15 '11 10:07

user84592


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.

How do I check my thread status?

Use Thread. currentThread(). isAlive() to see if the thread is alive[output should be true] which means thread is still running the code inside the run() method or use Thread.

What is JVM thread count?

A Oracle 32 bit JVM will default to 320kb stack size per thread. For a 32 bit JVM with 2gb of addressable memory this will give you a maximum of 6.5k threads.

What is a parked thread?

So a parked thread is a thread blocked using LockSupport.


1 Answers

These states are the same as mentioned in the Thread.State enum. "Wait" means, as the documentation says:

A thread is in the waiting state due to calling one of the following methods:

  • Object.wait with no timeout
  • Thread.join with no timeout
  • LockSupport.park

"Monitor" is the BLOCKED state, in which the thread is waiting to obtain a lock on an object (because it's trying to enter a synchronized block or method while another thread already holds the associated lock).

like image 67
Jesper Avatar answered Oct 12 '22 14:10

Jesper