# # 线程池# import time# from concurrent.futures import ThreadPoolExecutor## pool = ThreadPoolExecutor(15)### def task(n1):# time.sleep(1)# print(f‘任务{n1}‘)### num = int(input(‘请输入任务个数:‘))# for i in range(num)
# # 线程池# import time# from concurrent.futures import ThreadPoolExecutor## pool = ThreadPoolExecutor(15)### def task(n1):# time.sleep(1)# print(f‘任务{n1}‘)### num = int(input(‘请输入任务个数:‘))# for i in range(num):# pool.submit(task, i, num)## pool.shutdown(True)## print(‘ENd‘)## pool.map(task, range(100))# print(‘END‘)# 进程池import timefrom concurrent.futures import ProcessPoolExecutordef task(n1): time.sleep(0.2) print(f‘任务{n1}‘)if __name__ == ‘__main__‘: pool = ProcessPoolExecutor(10) for i in range(100): pool.submit(task, i) print(‘END‘)