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?
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.
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.
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.
So a parked thread is a thread blocked using LockSupport.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With