为什么 ArrayBlockingQueue 这两个条件参数名这么难理解

2020-12-08 22:56:56 +08:00
 luxinfl
/** Condition for waiting takes */
private final Condition notEmpty;

/** Condition for waiting puts */
private final Condition notFull;

当 put 的时候,如果队列满了,会调用 notFull.await() 为什么 notFull 这个参数不换成类似 producer.await()更好理解么? 同理当队列为空 take 的时候,notEmpty.await()换成 cosumer.await()。唤醒生产者的时候调用 producer.singal()

926 次点击
所在节点    程序员
1 条回复
xmt328
2020-12-09 08:55:49 +08:00
我觉得没问题啊,谁规定 blocking queue 就只能用在生产者消费者模式

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/733519

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX