https://blog.fastthread.io/2016/07/20/whats-the-difference-between-blocked-waiting-and-timed_waiting-explained-to-real-life-examples/
BLOCKED
Java doc formally defines BLOCKED state as: “A thread that is blocked waiting for a monitor lock is in this state.”
BLOCKED
Java doc formally defines BLOCKED state as: “A thread that is blocked waiting for a monitor lock is in this state.”
Titbit: A Thread will enter into BLOCKED state when it’s waiting for a monitor lock to enter a synchronized block/method or reenter a synchronized block/method after calling Object#wait() method.
WAITING
Java doc formally defines WAITING state as: “A thread that is waiting indefinitely for another thread to perform a particular action is in this state.”
Titbit: A Thread will enter into WAITING state when it’s calling one of the following methods:
- Object#wait() with no timeout
- Thread#join() with no timeout
- LockSupport#park()
Thread that has called Object.wait() on an object is in WAITING state until another thread to call Object.notify() or Object.notifyAll() on that object. A thread that has called Thread.join() is inWAITING state for a specified thread to terminate.
TIMED_WAITING
Java doc formally defines TIMED_WAITING state as: “A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state.”
Titbit: A Thread will enter into TIMED_WAITING state when it’s calling one of the following methods:
- Thread#sleep()
- Object#wait() with timeout
- Thread#join() with timeout
- LockSupport#parkNanos()
- LockSupport#parkUntil()