This question confused me a lot since I read its official explanation about Thread.State.
Blocked
A thread in the blocked state is waiting for a monitor lock to enter a synchronized block/method or reenter a synchronized block/method after calling Object.wait.
Waiting
A thread in the waiting state is waiting for another thread to perform a particular action. For example, a thread that has called Object.wait() on an object is waiting for another thread to call Object.notify() or Object.notifyAll() on that object. A thread that has called Thread.join() is waiting for a specified thread to terminate.
Also I read some wonderful answers like Difference between WAIT and BLOCKED thread states in StackOverflow, but still I am not quite sure about Waiting and Blocking.
Is it right to think about these two states as follows?
- Waiting: threads positively execute
wait()
orsleep()
to give up the CPU cycles; - Blocking: threads trying to move on but the essential resources like
synchronized block
are taken up by others, so they have to negatively be waited;