import threading
import time
from concurrent.futures import ThreadPoolExecutor
# 创建线程池
threadpool = ThreadPoolExecutor(max_workers= 20)
# 具体执行任务的方法
def test(i):
print(">>>>>>>>>>>>> 线程名称:%s 方法参数:%s" %(threading.current_thread().name,i))
def do_thread():
for i in range(0,20):
# 提交具体执行方法至线程池,返回 Future 对象
future_data = threadpool.submit(test,i)
# 关闭线程池
threadpool.shutdown()
if __name__ == '__main__':
do_thread()