gpt4 book ai didi

安卓线程 : how worker thread send signal to main(GUI) thread?

转载 作者:行者123 更新时间:2023-11-29 15:30:17 25 4
gpt4 key购买 nike

我有一个 gui 线程启动一个新线程来做一些忙碌的事情。 GUI 线程将等待工作线程完成,同时 GUI 需要响应。

伪代码:

主线程:

开始线程();wait_thread_done();

工作线程:

做某事();notify_main_thread();

在 android 中最简单的方法是什么?

最佳答案

最简单的方法是使用 Android 的 AsyncTask。文档在这里 http://developer.android.com/reference/android/os/AsyncTask.html

并且您可以调用 Activity.runOnUiThread() 从后台任务更新 UI。

关于安卓线程 : how worker thread send signal to main(GUI) thread?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7671024/

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