Thread: Multithreading of the underlying support module, generally not recommended to use;
Threading: Thread is encapsulated, some threads of the operation of the object, the general use of this method to achieve multithreaded programming
There are two modes of multithreaded implementations:
1. Create a function to execute the thread and pass the function into the thread object
2. Inherit directly from threading and create a new class,
Threading module:
Threading. Important functions of the thread class
Threading.currentthread (): Returns the current thread variable.
Threading.enumerate (): Returns a list that contains the running thread. Running refers to threads that do not include pre-and post-termination threads until after the thread has started and ends.
Threading.activecount (): Returns the number of running threads with the same result as Len (Threading.enumerate ()).
The start () method initiates thread activity
The is_alive () or IsAlive () method returns whether the thread is active or not.
Setdaemon () method
Isdaemon () method
The run () method is used to represent thread activity
The GetName () method returns the name of the thread
SetName () method to set the thread name
The join ([Time]) method waits until the thread aborts. This blocks the calling thread until the thread's join () method is called abort-gracefully exits or throws an unhandled exception-or an optional timeout occurs
This article is from the "mask_x blog" blog, please be sure to keep this source http://zhpfbk.blog.51cto.com/4757027/1886549
Python multi-Threading concurrent Processing module-threading