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?
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).