#线程共享
import threading
num = list(range(1000))
def set(num,lock):
lock.acquire()
for i in num[-1:0:-1]:
num[i] = 0
lock.release()
def test(num,lock):
lock.acquire()
for i in num:
print(i)
lock.release()
if __name__ == '__main__':
lock = threading.Lock()#创建锁对象
t1 = threading.Thread(target=set,args=(num,lock))
t2 = threading.Thread(target=test,args=(num,lock))
t2.start()
t1.start()
一直锁着把t2全部执行完
var code = “a42a58cb-7d61-4d2d-893c-c7305c596db6”