' Create thread ' from threading import thread# defines a function def Foo (ARG): Print (ARG) #创建一个线程对象, and establishes a relationship with the function Foo above, args= Pass a value of 100 as parameter to the Foo function print ("Start creating thread ...") T1 = Thread (target=foo,args= ()) t2 = Thread (target=foo,args= (200,)) # Before execution, which thread is T1.setdaemon (True) #执行线程print ("Execution thread ...") T1.start () T2.start () #直到该线程执行完后才继续往下执行, which can pass in a value (number), Set the wait Time T1.join () #查看是否等子线程结束后主线程才退出的设置, the default value is false to indicate that it is not the main thread, meaning that it will wait until the child thread finishes executing, and the main line friend exit print (T1.isdaemon ()) Print ( T2.isdaemon ()) #查看线程的名字, the SetName () method is to set the thread's name print (T1.getname ()) print (T2.getname ())
This article is from the "Q Group: 223843163" blog, please be sure to keep this source http://freshair.blog.51cto.com/8272891/1896634
Python multi-thread creation threads