python 5. 线程池 与 进程池
1. 线程池使用
注意 : ProcessPoolExecutor 进程池 不好用 同进程一样
from concurrent.futures import ThreadPoolExecutor,ProcessPoolExecutor def fn(name): for i in range(10): print(name, i) if __name__ == '__main__': #创建线程池 with ThreadPoolExecutor(10) as t: for i in range(10): t.submit(fn, name=f'线程{i}') print('over!')