本文介绍了ThreadPoolExcutor和invokeAll列表顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 ThreadPoolExcutor
.我想知道如果在 invokeAll
方法中,我可以确定输出( Future
对象)的顺序将与输入( Callable
列表).
I'm working on ThreadPoolExcutor
.I would like to know if in invokeAll
method, I can be sure that the output (Future
objects) order is going to be the same as the input (Callable
list).
List<Future<T>> invokeAll(List<Callable<T>> tasks)
推荐答案
所保证的是,返回的期货清单的顺序与您给出的清单迭代器的顺序相同.请注意,此方法仅在所有任务完成后返回.
What is guaranteed is that the list of futures returned has the same order that the list's iterator you're giving. Note that this method only returns when all tasks have been completed.
引用 invokeAll(任务)
Javadoc:
Quoting invokeAll(tasks)
Javadoc:
这篇关于ThreadPoolExcutor和invokeAll列表顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!