前置知识: Python

多进程与多线程

00:00
1 min Intermediate 2026/6/14

threading与multiprocessing

1. 多线程

from concurrent.futures import ThreadPoolExecutor

with ThreadPoolExecutor(max_workers=4) as pool:
  results = pool.map(fetch_url, urls)

2. 多进程

from multiprocessing import Pool

with Pool(4) as pool:
  results = pool.map(heavy_compute, data)

3. GIL 限制

场景推荐
IO 密集多线程/协程
CPU 密集进程

知识检测

学习进度

-- 已学文档
--% 知识覆盖率

学习推荐

专注模式