python多線程和多進程使用

# 多線程
from concurrent.futures import ThreadPoolExecutor
# 多進程
from concurrent.futures import ProcessPoolExecutor

import time

def task(i):
    print(i)
    time.sleep(1)

pool = ThreadPoolExecutor(10)
for index in range(1000):
    pool.submit(task,index)

print('end')
相關文章
相關標籤/搜索