concurrent.futures之ThreadPoolExecutor python线程池代码实现方法

from concurrent.futures import ThreadPoolExecutor

def main(i):
     print(i)

THREAD_NUM = 20  # 线程数
with ThreadPoolExecutor(THREAD_NUM) as t:
    for i in range(1, 100):
        t.submit(main, i)

 

posted @ 2022-11-08 23:14  zk-b-bull  阅读(49)  评论(0)    收藏  举报