我不明白区别。帮助我观察这种差异。那么ProcessPoolExecutor呢,他的行为是一样的吗?使用方法ThreadPoolExecutor.shutdown(wait = True),shutdown(wait = False)和不使用此方法之间有什么区别?
def func(task):
do_something(task)
tasks = [task for i in range(12)]
executor = ThreadPoolExecutor(4)
executor.map(func, tasks)
executor.shutdown(wait=True) # ok, here the main thread waits for others
tasks = [task for i in range(12)]
executor = ThreadPoolExecutor(4)
executor.map(func, tasks)
executor.shutdown(wait=False) # here it doesn't wait and what can happens bad?
tasks = [task for i in range(12)]
executor = ThreadPoolExecutor(4)
executor.map(func, tasks) # if i don't call shutdown ?
https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Executor.shutdown – njzk2 2015-02-09 19:19:02
我读过了。只是等待所有线程完成的方法分配? – r45i 2015-02-09 19:23:51
我不明白你的意见。 – njzk2 2015-02-09 19:24:37