在Android的处理程序,尺蠖实施 [英] Handler-Looper implementation in Android
问题描述
- 在我有一个处理程序(UI线程)活动
- 在我开始新的主题,使handler.post(新MyRunnable()) - (新的工作线程)
Android的文档中的有关方法后说:导致了Runnable r以被添加到消息队列中的可运行将是此处理器相连接的线程上运行。
处理器连接到UI线程。 如何机器人可以运行可运行在没有新的线程创建相同的UI线程?
时的新的线程将使用从handler.post Runnable接口创建()? 或者它只是run()方法将从Runnable的子类叫什么名字?
处理器连接到UI线程。
正确的。
如何机器人可以运行可运行在同一个UI线程没有新的线程创建?
任何线程,包括主应用程序(UI)线程,可以调用后()在处理程序
(或任何查看
,对于这个问题)。
- I have Activity with Handler (UI thread)
- I start new Thread and make handler.post(new MyRunnable()) - (new work thread)
Android documentation said about post method: "Causes the Runnable r to be added to the message queue. The runnable will be run on the thread to which this handler is attached."
Handler attached to UI thread. How android can run runnable in the same UI thread without new thread creation?
Is new thread will be created using Runnable from handler.post()? Or it's only run() method will be called from Runnable subclass?
Handler attached to UI thread.
Correct.
How android can run runnable in the same UI thread without new thread creation?
Any thread, including the main application ("UI") thread, can call post() on Handler
(or on any View
, for that matter).
这篇关于在Android的处理程序,尺蠖实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!