import threading
defthread_job_1():# 线程功能print("This is a added Thread, number is %s"% threading.current_thread())defthread_job_2():print("This is a added Thread, number is %s"% threading.current_thread())defmain():
added_thread_1 = threading.Thread(target=thread_job_1)#添加线程并指明功能
added_thread_2 = threading.Thread(target=thread_job_2)
added_thread_1.start()# 开启线程
added_thread_2.start()print(threading.active_count())# 查看有多少激活了的线程print(threading.enumerate())# 查看激活的哪几个线程print(threading.current_thread())# 查看正在运行的是哪个线程if __name__ =="__main__":
main()
python Threading多线程一、添加线程import threadingdef thread_job_1(): # 线程功能 print("This is a added Thread, number is %s" % threading.current_thread()) def thread_job_2(): print("This is a added Thread, number is %s" % threading.current_thread())