#!/usr/bin/env python # -*- coding:utf-8 -*- from concurrent.futures import ThreadPoolExecutor #线程池,导入模块 import time def task(hostname): ‘‘‘ 假设这里是要提交的任务 :param hostname: :return: ‘‘‘ time.sleep(2) print(hostname) #创建线程池线程数自定义,要看主机性能,例如创建20个线程 pool = ThreadPoolExecutor(20) for i in range(1,101): #100个任务 hostname = ‘c{}.com‘.format(i) pool.submit(task,hostname
原文地址:https://www.cnblogs.com/michael2018/p/10422600.html
时间: 2024-10-11 00:52:10