A lot of people have been unable to understand why multithreading is used , It can be understood in this way , It's like a highway , If only one truck is allowed to carry the goods at a time , Obviously, no matter how fast you run , It's just a car , There's still room for the entire Freeway , It's not efficient to use the freeway . If we let more cars carry the goods , It's not the same . So multithreading is like having more cars ,CPU It runs very fast , If only one thread is running , So, like the freeway, there's free space . Multiple threads are running , Whole CPU The efficiency of the overall improvement of efficiency . Of course , The more threads, the better , When the number of threads reaches a certain number , It's going to peak , There is no definite number of details , It depends on what the task is .
stay Python In the threading Module provides thread class Thread, You can create and start threads . The constructor is as follows :
class threading.Thread(group=None, target=None, name=None, args=(), kwargs={}, *, daemon=None)
group Is a reserved parameter , Not used temporarily .