标签:style logs 使用 sleep UI global 线程锁 int lock
1 import threading 2 import time 3 globals_num = 0 4 lock = threading.RLock() 5 def func(): 6 lock.acquire()#获得锁 7 global globals_num 8 globals_num += 1 9 time.sleep(1) 10 print(globals_num) 11 lock.release()#释放锁 12 13 for i in range(10): 14 t = threading.Thread(target=func) 15 t.start()
标签:style logs 使用 sleep UI global 线程锁 int lock
原文地址:http://www.cnblogs.com/shiluoliming/p/6442764.html