标签:read 其他 isa __name__ isp one audio isalive class
from threading import Thread,currentThread,active_count import time def task(): print(‘%s is running‘ % currentThread().getName()) time.sleep(2) print(‘%s is end‘%currentThread().getName()) if __name__ == ‘__main__‘: t = Thread(target=task,name = ‘子线程1‘) #可以用name定义线程名字 t.start() t.join() t.setName(‘儿子线程1‘) #可以更改线程名字 currentThread().setName(‘zhu‘) #更改主线程名字 print(t.isAlive()) print(‘zhu‘,currentThread().getName()) print(active_count()) #活跃线程数量
标签:read 其他 isa __name__ isp one audio isalive class
原文地址:https://www.cnblogs.com/yelublue/p/9122545.html