sách gpt4 ăn đã đi

android - 从另一个 AsyncTask 调用 AsyncTask

In lại Tác giả: IT Lão Cao 更新时间:2023-10-28 21:54:24 26 4
mua khóa gpt4 giày nike

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

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

Cảm ơn!

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

câu trả lời hay nhất

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

是的,但仅限于 onProgressUpdate() hoặc 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/

26 4 0
Cựu chiến binh CNTT
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress