AsyncTask 是根据其每个参数顺序还是随机运行 doInBackground? [英] Does AsyncTask run the doInBackground accordingly to each of its parameter order or randomly?

查看:45
本文介绍了AsyncTask 是根据其每个参数顺序还是随机运行 doInBackground?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,有一个字符串的 AsyncTask... parameters ,如果我这样调用:

For example there is an AsyncTask of a String... parameters , if I make a call like this :

AsyncTask<String, Void, Void> someTask = new myTask(myActivity.this);
someTask.execute(string1 , string2 , string3);

在这个任务中 doInBackground 的内部执行顺序是什么:它是先处理 string1,然后是 string2 等等,因为它们在调用时提供,还是它处理 参数随机?

What is the internal order of execution of the doInBackground inside this task : does it treat string1 first then string2 and so on sequencely as they are provided when called , or does it treat the parameters randomly ?

推荐答案

String... 是一个vararg",在本例中将所有单独的参数转换为 String[],其中条目到数组按照它们传入方法的顺序排列.

String... is a "vararg", which in this example converts all individual parameters into a String[], where the entries to the array are in the order they got passed into the method.

所以使用你的例子,(String[]) param[0] == string1, param[1] == string2param[2] == string3 等等.这是为了param条目的排序,至于如何使用param中的每个条目,这完全取决于您的代码.

So using your example, (String[]) param[0] == string1, param[1] == string2, param[2] == string3 and so forth. This is for the ordering of param entries, as to how each entry in param is used, it depends entirely on your code.

这篇关于AsyncTask 是根据其每个参数顺序还是随机运行 doInBackground?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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