标签:port rom pre release class ase pytho python nbsp
import time from threading import Thread,Lock,RLock def f1(locA,locB): locA.acquire() print(‘f1>>1号抢到了A锁‘) time.sleep(1) locB.acquire() print(‘f1>>1号抢到了B锁‘) locB.release() locA.release() def f2(locA,locB): locB.acquire() print(‘f2>>2号抢到了B锁‘) locA.acquire() time.sleep(1) print(‘f2>>2号抢到了A锁‘) locA.release() locB.release() if __name__ == ‘__main__‘: locA = Lock() locB = Lock() t1 = Thread(target=f1,args=(locA,locB)) t2 = Thread(target=f2,args=(locA,locB)) t1.start() t2.start()
标签:port rom pre release class ase pytho python nbsp
原文地址:https://www.cnblogs.com/demons97/p/10268210.html