程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

python mutiprocessing threading ThreadPoolExector

編輯:Python

1、threading In fact, it can not achieve actual multithreading concurrency , At some point ta Only one thread can execute , However, due to the fast switching between threads , It will be assumed that multiple threads execute at the same time .

2、mutiprocessing It's multi process ,ta Concurrent operation can be achieved .

3、ThreadPoolExector Thread pool ,ta What's special is that you can create a specified number of thread pools , Maximize the rational use of resources , And and threading Better defensive than It is not easy to cause program crash .

We all know that using threads and processes can improve the execution efficiency of programs , However, it should be noted that not all programs can be improved when using multithreading and multiprocessing , Next, through the data experiment , We can see that multithreading is going on cpu Intensive computing does not improve efficiency, but will be more time-consuming than ordinary single thread .

  According to the experimental results, we come to the conclusion that cpu In intensive computing, we can use multiple processes to improve execution efficiency , stay io In intensive computing, we can choose multithreading to improve execution efficiency .

  The figure shows the comparison of common methods of multithreading and multiprocessing , Please like the collection comments …

If you have a deeper understanding of the relevant content, take a look at the video explanation of this blogger ~【【2021 The latest version 】Python Concurrent programming practice , With multithreading 、 Multi process 、 Multi process acceleration program running - Bili, Bili 】 https://b23.tv/6wF7v3s


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved