多线程锁

import threading
import time
num = 0
lock = threading.RLock()

def fun():
lock.acquire()
global num
num+=1
time.sleep(1)
print(num)
lock.release()

for i in range(10):
t =threading.Thread(target=fun)
t.start()
posted @ 2017-03-02 21:15  Erick-LONG  阅读(148)  评论(0编辑  收藏  举报