在Android的处理程序,尺蠖实施尺蠖、程序、Android

2023-09-06 17:32:04 作者:没公主命就别犯公主病

在我有一个处理程序(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?

阿里聚安全 安全周刊 安卓应用变身流量小偷 丨黑客世界杯Pwn2Own日期公布

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).

 
精彩推荐
图片推荐