There are 3 states for a thread that is alive but is neither running not runnable:-
- Sleeping
- Blocked
- Waiting
When a thread executes sleep() method, it goes into SLEEPING state from running state for the time period specified by its argument (say for some milliseconds).
When a thread is waiting for a lock on an object that is acquired by some other thread because of the synchronized method or block, it is BLOCKED by that thread.
So, can we say that a thread enters WAITING state when it executes wait() on some other thread?
Same is the case with calling join() on some thread.
So, can we say that both wait() (from java.lang.Object) and join() (from java.lang.Thread) shifts a thread's state to WAITING?