01 线程的其他方法
import threading import time from threading import Thread,current_thread def f1(n): time.sleep(1) print('子线程名称', current_thread().getName()) #Thread-1 print('%s号线程任务'%n) if __name__ == '__main__': t1 = Thread(target=f1,args=(1,)) t1.start() print('主线程名称',current_thread().getName()) #MainThread print('主线程ID',current_thread().ident) print(current_thread()) print(threading.enumerate()) #[<_MainThread(MainThread, started 6708)>, <Thread(Thread-1, started 7848)>] print(threading.active_count()) # print('主线程')