gpt4 book ai didi

java - ThreadPoolExcutor 和 invokeAll 列表顺序

转载 作者:行者123 更新时间:2023-12-03 18:59:04 28 4
gpt4 key购买 nike

我正在研究 ThreadPoolExcutor
我想知道是否在 invokeAll 方法中,我可以确定输出( Future 对象)的顺序将与输入( Callable 列表)相同。

List<Future<T>> invokeAll(List<Callable<T>> tasks)

最佳答案

保证返回的 future 列表与您提供的列表迭代器的顺序相同。请注意,此方法仅在所有任务完成后才返回。

引用 invokeAll(tasks) Javadoc:

Returns: a list of Futures representing the tasks, in the same sequential order as produced by the iterator for the given task list, each of which has completed

关于java - ThreadPoolExcutor 和 invokeAll 列表顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34158081/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com