import os
import threading
import time
from threading import Thread
from concurrent.futures import ThreadPoolExecutor
threadPool = ThreadPoolExecutor(max_workers=5,thread_name_prefix="test_")
def test(v1,v2):
print(threading.current_thread().name,v1,v2)
time.sleep(2)
if __name__=='__main__':
for i in range(0,10):
threadPool.submit(test,i,i+1)
threadPool.shutdown(wait=True)
python线程池使用样例
最新推荐文章于 2022-05-30 22:17:24 发布