摘要: 首先看一个例子,让我们lock = threading.Lock() 时(代码第33行),程序会卡死在这里 如果我们将其改为lock = threading.RLock(),那么程序就能正常运行,这个就是递归锁 RLock() 阅读全文
posted @ 2018-09-03 10:39 。低调ヽ继续 阅读(223) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python import threading,time def run(n): # 申请锁 semaphore.acquire() time.sleep(1) print("run thre thread:%s\n"%n) # 释放锁 semaphore.release() if __name__ == "_... 阅读全文
posted @ 2018-09-03 10:22 。低调ヽ继续 阅读(189) 评论(0) 推荐(0) 编辑