进程池import timefrom concurrent.futures import ProcessPoolExecutordef task(arg):time.sleep(2)print(arg)if __name__ == __main__:pool = ProcessPoolExecutor(5)for i in range(20):pool.submit(task, i)...
进程池
import time
from concurrent.futures import ProcessPoolExecutor
def task(arg):
time.sleep(2)
print(arg)
if __name__ == '__main__':
pool = ProcessPoolExecutor(5)
for i in range(20):
pool.submit(task, i)
线程池
import time
from concurrent.futures import ThreadPoolExecutor
def task(arg):
time.sleep(2)
print(arg)
if __name__ == '__main__':
pool = ThreadPoolExecutor(5)
for i in range(20):
pool.submit(task, i)
沃梦达教程
本文标题为:python线程池/进程池创建
基础教程推荐
猜你喜欢
- Python基础学习之函数和代码复用详解 2022-09-02
- centos系统 anaconda3(python3)安装pygrib 2023-09-04
- CentOS 7.5 安装 Python3.7 2023-09-03
- python的环境conda简介 2022-10-20
- 基于Python实现股票数据分析的可视化 2023-08-04
- 四步教你学会打包一个新的Python模块 2022-10-20
- Centos7下安装python环境 2023-09-04
- Python爬取当网书籍数据并数据可视化展示 2023-08-11
- ubuntu 18 python3.6 的安装与 python2的版本切换 2023-09-03
- Python 中 Elias Delta 编码详情 2023-08-08