dequanth

导航

线程状态中的阻塞究竟该如何理解?

康师傅给定的从线程状态划分的转换关系

idea中源码对BLOCKED和WAITTING的解释说明

BLOCAED:
    Thread state for a thread blocked waiting for a monitor lock. 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.
WAITTING:
	Thread state for a waiting thread. A thread is in the waiting state due to calling one of the following methods:
Object.wait with no timeout
Thread.join with no timeout
LockSupport.park
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.

通过对比可知,康师傅是吧源码中的BLOCKED和WAITTING以及TIMED-WAITTING都一并归入了阻塞的状态。
所以,对于这个阻塞,大家平时都是怎么理解的呢?

posted on 2022-10-01 21:52  dequantianhe  阅读(30)  评论(0编辑  收藏  举报