import threading,time
def run():
time.sleep(3)
print('哈哈哈')
start_time = time.time()
threads = [] #存放啓動的5個線程
for i in range(5):
t = threading.Thread(target=run)
t.start()
# t.join()-------主線程等待子線程執行結束----此處放置等待啓動一個進程等待一次,至關於串行
threads.append(t)app
for lyl in threads: #主線程循環等待5個子線程執行結束
lyl.join()
end_time = time.time()
print('run_time..',end_time-start_time)線程