摘要:        
一、递归锁 # Lock :互斥锁 效率高 # RLock :递归(recursion)锁 效率相对低 在同一个线程中可以被acquire多次,如果想要释放锁,acquire多少次就要release多少次 from threading import RLock def func(i,rlock):     阅读全文
posted @ 2020-05-12 15:21
佛祖让我来巡山
阅读(353)
评论(0)
推荐(0)
        
            
        
        
摘要:        
一、多个线程对同一个数据进行修改 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    阅读全文
posted @ 2020-05-12 15:12
佛祖让我来巡山
阅读(361)
评论(0)
推荐(0)
        
            
        
        
摘要:        
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    阅读全文
posted @ 2020-05-12 15:04
佛祖让我来巡山
阅读(283)
评论(0)
推荐(0)
        

浙公网安备 33010602011771号