标签:进程 count() int print thread pen finish highlight port
import threading,time def run(n): print("task is ",n) time.sleep(2) print("task done", n) start_time =time.time() t_objs = []#存线程实例 for i in range(50): t = threading.Thread(target=run,args=("t-%s"%i,)) t.setDaemon(True)#设为守护进程 t.start() t_objs.append(t) #for t in t_objs: #t.join() #第二个参数查看是否是主线程还是子线程,第三个参数是查看活动线程 print("all threads has finished",threading.current_thread(),threading.active_count()) print("cost:",time.time()-start_time)
标签:进程 count() int print thread pen finish highlight port
原文地址:https://www.cnblogs.com/fuyuteng/p/9195160.html