java producer consumer problem# JobHunting - 待字闺中
c*n
1 楼
,我记得以前 sun/oracle 网站上tutorial 讲这个问题时是用两个 conditional
variable ( which encapsulates their own locks). notify() wait() 来做的。
现在网站上的文档成了一个 信号, 这样 full 和 empty 时候所有的 producer 或
consumer 都会唤醒, 浪费。
用explicit. java.concurrent lock. and conditional variable 可以写出来, 但如
果用 primitive 怎么写呢?
variable ( which encapsulates their own locks). notify() wait() 来做的。
现在网站上的文档成了一个 信号, 这样 full 和 empty 时候所有的 producer 或
consumer 都会唤醒, 浪费。
用explicit. java.concurrent lock. and conditional variable 可以写出来, 但如
果用 primitive 怎么写呢?