I use JConsole to watch a thread, it shows
name: Thread-6
state:BLOCKED sun.misc.Launcher$AppClassLoader@19821f ,owner: Thread-3
blocked Count:199,645 Waited Count: 2,610
199,645 and 2,610: Is that a bad thing?
If your application is not running meeting your requirements, based on these numbers that would be because there is a lot of lock contention. Waiting is that it waits for a notification (Object.wait()) but blocked means that it tries to acquire a lock and cannot because another thread holds it.
From http://geekexplains.blogspot.ca/2008/07/threadstate-in-java-blocked-vs-waiting.html
Difference between BLOCKED state and WAITING / TIMED_WAITING states?
When a thread calls Object.wait method, it releases all the acquired monitors and is put into WAITING (or TIMED_WAITING if we call the timeout versions of the wait method) state. Now when the thread is notified either by notify() or by notifyAll() call on the same object then the waiting state of the thread ends and the thread starts attempting to regain all the monitors which it had acquired at the time of wait call. At one time there may be several threads trying to regain (or maybe gain for the first time) their monitors. If more than one threads attempt to acquire the monitor of a particular object then only one thread (selected by the JVM scheduler) is granted the monitor and all other threads are put into BLOCKED state.
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