5.1.2 线程锁
i = 0
lock = threading.Lock()
def think():
global i
lock.acquire()
i += 1
lock.release()lock = threading.Lock()
def think():
global i
with lock:
i += 1Last updated
i = 0
lock = threading.Lock()
def think():
global i
lock.acquire()
i += 1
lock.release()lock = threading.Lock()
def think():
global i
with lock:
i += 1Last updated