作者sean72 (.)
看板Python
標題[問題] blocking queue 實作
時間Wed Jul 18 15:13:52 2018
實現一個 thread safe, blocking bounded Queue
my implementation
https://paste.ubuntu.com/p/697Qv8dRtR/
follow up
必須支援multi put
我這樣的做法有滿足要求嗎?
我不是很了解multi put的意思 (網上分享的面試題目,描述也不是很完全
我在MyQueue裡面用condition實現了blocking的功能
如果我有多個producer thread 1 2 3, 只要任一個producer執行了put,
我的condition lock應該可以滿足multi put + thread safe + blocking 吧?
感謝各位大俠
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 172.89.32.145
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1531898036.A.884.html
推 cutekid: 應該有滿足! 07/18 22:40
推 flarehunter: 在空的時候同時有2個get()和1個put()可能會壞掉 07/20 23:30
→ flarehunter: 有兩個MyQueue物件也會壞掉 另外為什麼要繼承Thread? 07/20 23:31
※ 編輯: sean72 (76.169.162.97), 04/26/2019 02:14:05