ThreadPoolExcutor和invokeAll列表顺序 [英] ThreadPoolExcutor and invokeAll list order

查看:78
本文介绍了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.

引用

Quoting 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

这篇关于ThreadPoolExcutor和invokeAll列表顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆