import time
import threading
lst=[]
lock=threading.RLock()
def fun(arg):
lock.acquire()
lst.append(arg)
time.sleep(1)
m=lst[-1]
print(arg,m)
lock.release()
for i in range(10):
t=threading.Thread(target=fun,args=(i,))
t.start()
import time
import threading
lst=[]
lock=threading.Lock()
def fun(arg):
lock.acquire()
lst.append(arg)
time.sleep(1)
m=lst[-1]
print(arg,m)
lock.release()
for i in range(10):
t=threading.Thread(target=fun,args=(i,))
t.start()