[問題] blocking queue 實作

看板Python作者 (.)時間7年前 (2018/07/18 15:13), 6年前編輯推噓2(202)
留言4則, 2人參與, 7年前最新討論串1/4 (看更多)
實現一個 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

07/18 22:40, 7年前 , 1F
應該有滿足!
07/18 22:40, 1F

07/18 22:41, 7年前 , 2F

07/20 23:30, 7年前 , 3F
在空的時候同時有2個get()和1個put()可能會壞掉
07/20 23:30, 3F

07/20 23:31, 7年前 , 4F
有兩個MyQueue物件也會壞掉 另外為什麼要繼承Thread?
07/20 23:31, 4F
※ 編輯: sean72 (76.169.162.97), 04/26/2019 02:14:05
文章代碼(AID): #1RJkYqY4 (Python)
文章代碼(AID): #1RJkYqY4 (Python)