Java线程 Block和Waiting的异同
可以参考文章
http://stackoverflow.com/questions/2534147/java-thread-wait-blocked
我的理解
1 相同点
线程都不是运行状态
2 不同点
waiting是在资源的等待队列中,等待被notify,notify后将会到Runable状态,
但是要想运行还得过monitor这关。
参考
In other words, both BLOCKED and WAITING are status of inactive threads, but a WAITING thread cannot be RUNNABLE without going to BLOCKED first. WAITING threads "don't want" to become active, whereas BLOCKED threads "want" to, but can't, because it isn't their turn.
本文探讨了Java线程中的Blocked与Waiting状态的区别与联系。Blocked状态下的线程试图获取锁但未成功;而Waiting状态下的线程正在等待其他线程的通知。Waiting状态的线程在接收到通知后会进入Runnable状态,但仍需获取锁才能继续执行。
1049

被折叠的 条评论
为什么被折叠?



