What is difference between BLOCKED and WAITING state in java multithreading?

(Last Updated On: September 27, 2015)

Answer: Difference between blocked and waiting state of Java thread.

BLOCKED state: If a thread is waiting for a lock to enter a synchronized block/method is called blocked.

Note – Also, when a thread wants to re-enter a synchronized block/method after calling wait () method is also called blocked.

WAITING state: a thread, that is waiting indefinitely 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.

 

Notes:

A thread can enter the waiting state due to calling one of the following methods:

  • thread.wait()
  • thread.join()with no time out.

A thread that has called thread.join() must wait for its child thread finish execution and terminate.

Conclusion:

In any case if a thread is waiting for a lock to enter synchronized block/ method is called as blocked. And, if a thread is waiting indefinitely for another thread to complete the task and notify is called as in waiting state.