摘要: Condition版的生产者和消费者模式 threading.Condition 在没有数据的时候处于阻塞状态,有数据可以使用notify的函数通知等等待状态的线程运作 threading.Condition 实际上是继承threading.Lock acquire:上锁。 release:解锁。 阅读全文
posted @ 2019-02-20 20:38 st--st 阅读(166) 评论(0) 推荐(0) 编辑
摘要: ''' Lock版的生产者和消费者模式 ''' import threading import random import time gMoney = 1000 # 原始金额 gLoad = threading.Lock() gTime = 0 # 生产次数 class Producer(threading.Thread): def run(self... 阅读全文
posted @ 2019-02-20 20:06 st--st 阅读(117) 评论(0) 推荐(0) 编辑