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')

  

posted @ 2017-04-25 13:51  隔壁Mr.Wang  阅读(255)  评论(0编辑  收藏  举报