python如何保证多个线程同时修改共享对象时不出错!
摘要:
import threadingimport timenumber = 0lock = threading.RLock() #是Lock()的升级版,用Rlock()即可def run(num): lock.acquire() #跟cpu申请一把锁 global number number +=1 阅读全文
posted @ 2017-01-10 18:12 游走的鱼 阅读(141) 评论(0) 推荐(0) 编辑