摘要:
一、递归锁 # Lock :互斥锁 效率高 # RLock :递归(recursion)锁 效率相对低 在同一个线程中可以被acquire多次,如果想要释放锁,acquire多少次就要release多少次 from threading import RLock def func(i,rlock): 阅读全文
摘要:
一、多个线程对同一个数据进行修改 from threading import Thread,Lock n = 0 def add(lock): for i in range(500000): global n with lock: n += 1 def sub(lock): for i in ran 阅读全文
摘要:
import time from threading import Thread def son(): while True: print('in son') time.sleep(1) def son2(): for i in range(3): print('in son2 ****') tim 阅读全文