gpt4 book ai didi

android - 从另一个 AsyncTask 调用 AsyncTask

转载 作者:IT老高 更新时间:2023-10-28 21:54:24 25 4
gpt4 key购买 nike

在我的 AsyncTask 的某个时刻,在完成一些验证之后,我需要派生另一个线程来做一些其他工作。所以我现在想要两个后台线程,每个都做自己的事情(每个执行大约 2-3 秒)。我们的想法是最大限度地提高 Atrix 等双核处理器的性能。

创建另一个异步任务并从第一个执行它是否可以接受?任何人都可以提出更好的方法吗?

谢谢!

编辑:我想知道第二个任务中的 publishProgress() 甚至会做什么......因为它不是从 Activity 启动的?

最佳答案

Is it acceptable to create another asynctask & execute it from the first one?

是的,但仅限于 onProgressUpdate()onPostExecute() 内部,因为这些方法在 UI 线程上运行。因此,通过选择上面列出的两种方法之一在 UI 线程上启动第二个 AsyncTask

I'm wondering what publishProgress() from the second task would even do... since it was not started from an Activity?

它的作用完全相同,因为您是从 UI 线程启动它。

关于android - 从另一个 AsyncTask 调用 AsyncTask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5779894/

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