BLOCKED - this state represents a thread which has been blocked and is waiting for a moniotor to enter/re-enter a synchronized block/method. A thread gets into this state after calling Object.wait method.
WAITING - this state represnts a thread in the waiting state and this wait is over only when some other thread performs some appropriate action. A thread can get into this state either by calling - Object.wait (without timeout), Thread.join (without timeout), or LockSupport.park methods.
BLOCKED是指線程正在等待獲取鎖剖张;WAITING是指線程正在等待其他線程發(fā)來的通知(notify),收到通知后恰起,可能會順序向后執(zhí)行(RUNNABLE)修械,也可能會再次獲取鎖,進(jìn)而被阻塞准炫巍(BLOCKED)肯污。
PS:
notify與notifyAll的區(qū)別
notify是將某個waiting的線程狀態(tài)改變?yōu)閎locked(由于notify的線程尚未退出臨界區(qū),尚未釋放鎖吨枉,所以被喚醒的線程狀態(tài)變?yōu)閎locked)蹦渣,notifyAll是將所有線程的狀態(tài)改變?yōu)閎locked。