标签:start 多线程 imp 一个 end -- sleep thread reads
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)
for lyl in threads: #主线程循环等待5个子线程执行结束
lyl.join()
end_time = time.time()
print(‘run_time..‘,end_time-start_time)
标签:start 多线程 imp 一个 end -- sleep thread reads
原文地址:https://www.cnblogs.com/lynn-chen/p/9117971.html