缩减版多线程

import threading
lock = threading.Lock()

def th_001(req):
lock.acquire()
print(req,time.asctime())
lock.release()

def test():
pool=[]
for i in range(1000):
th=threading.Thread(target=th_001,args=(i,))
th.start()
pool.append(th)
for t in pool:
t.join()


if __name__ == '__main__':

test()
posted @ 2019-11-22 16:13  不带R的墨菲特  阅读(117)  评论(0编辑  收藏  举报