标签:utf-8 read active target == [] count 活跃 主线程
# -*- coding:utf-8 -*-
# Author:Brownyangyang
import threading
import time
def sayhi(num):
print("running on number:%s" %num,threading.current_thread(),threading.active_count()) ##打印线程
#threading.current_thread() 当前县称号
#threading.active_count() 活跃线程个数
time.sleep(2)
#if __name__ == ‘__main__‘:
start_time=time.time()
item_liyan = []
for i in range(50):
t = threading.Thread(target=sayhi,args=(i,))
t.start()
#t2.start()
item_liyan.append(t)
for j in item_liyan:
j.join()
print("time %s",time.time()-start_time)
print(threading.current_thread()) ##打印主线程
#print(t1.getName())
#print(t2.getName())
标签:utf-8 read active target == [] count 活跃 主线程
原文地址:https://www.cnblogs.com/brownyangyang/p/8900668.html