3

notifyAll唤醒线程的范围?

 3 years ago
source link: https://www.oschina.net/question/2652412_2322464
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

notifyAll唤醒线程的范围?

sprouting 发布于 昨天 16:56

最近在看《java并发编程》,看到 notifyAll  的时候有一个疑问, notifyAll 唤醒的是全部的线程,还是唤醒当前这个锁等待的线程?

假设我有两个锁, A锁有5个线程在等待,B锁有3个线程在等待,A锁中的线程执行完了,调用 notifyAll ,是唤醒了 A B 两个锁的全部的等待线程还是只唤醒了 A锁的5个线程?

个人认为是只唤醒了A锁等待池中的5个,而不是全部8个,求大佬讲解下。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK