作者Yshuan (倚弦)
看板Python
标题Re: [问题] thread-safe queue
时间Fri Apr 26 12:20:16 2019
que size已满. 三个Thread.
producer: Ta, Tb.
consumer: T1.
0. producer都先启动. 并且停在wait()
1. T1执行, 执行完後notify Ta.
2. Ta结束wait, 执行完後
notify Tb
因为你的condition只有一个, 因此造成producer notify producer.
3. Tb结束wait. 执行并que overflow.
反之在que size已空, 2个getter先行并wait, 1个putter也有同样结果.
--
∕∕∕∕∕∕∕有一个洋将 名字叫汤姆 他是一个戴着眼镜的孩子 词φrei196
▆▇ moc
∕ 在棒球场里 东奔西跑 站外野 当投手 三振K金 by arsia
╴
∕ 汤姆 汤姆 143公里
▅▃▃▂ ∕ 汤姆 汤姆 充满活力 \囧/ \囧/ \囧/ http://0rz.net/cb1xE
██︵█︵ ∕ 为保留饭碗 不怕冒险 甲 杰 贺 ξ
██▄︽▄∕∕为了帮助球队 不怕困难 /\ // \\ 囧威z ╭─────
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 118.163.84.235
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1556252422.A.689.html
1F:→ adrianshum: 用notifyAll 应该就行吧?虽然稍欠效率就是了 04/26 21:44