时间:2021-01-06 11:24:00 | 栏目:Python代码 | 点击:次
def test_func(id):
for i in range(0,5):
sleep(1)
print('thread %d is running %d' % (id,i))
threads = []
for i in range(0,3):
t = threading.Thread(target=test_func, args=(i,))
threads.append(t)
for t in threads:
t.start()
for t in threads:
t.join()