标签:start get read pen for port 结束 print 子线程
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()
threads.append(t)
print(‘threads‘,threads)
# t.join() #主线程等待子线程执行结束
for t in threads: #主线程循环等待5个子线程执行结束
t.join() #循环等待,等待5个线程都结束
end_time=time.time()
run_time=end_time-start_time
print(‘run_time..‘,run_time)
标签:start get read pen for port 结束 print 子线程
原文地址:https://www.cnblogs.com/jiadan/p/9120850.html