#-*-coding:utf-8-*-__author__ = ' magicpwn ' import threadingimport timeimport queuedef worker (): Print Threading.curren T_thread (). GetName () def worker2 (): For I in Range (0,1000): Print I time.sleep (1) threads = []for I In range (5): T = Threading. Thread (target=worker) #新创建线程, specifies the execution of a function, Threads.append (t) t.start () s = Threading. Thread (Target=worker2, args= ()) # daemon Thread daemon is set to true then it is a non-critical thread, and the main path does not wait for its end to end on the process. # set to False or default indicates the thread is important and the main thread waits for it to end before the process can be ended. # The daemon thread means that by default, or when the child thread Setdaemon (False) is set, the # main thread becomes the daemon thread of the child thread. When all threads end, the main thread ends the process. S.setdaemon (False) threads.append (s) s.start ()
This article is from the "Magicpwn" blog, make sure to keep this source http://magicpwn.blog.51cto.com/10497784/1683820
Python Threading Module