# coding: utf-8
import threading
import time
from concurrent.futures import ThreadPoolExecutor
def test():
for i in range(5):
print('running thread id : %d now=%d'% (threading.get_ident(),i) )
time.sleep(1)
#: 生成线程池 最大线程为50个
pool = ThreadPoolExecutor(5)
#: test
for i in range(100):
pool.submit(test) #提交并运行
转载于:https://my.oschina.net/tasker/blog/843055