您的位置:首页 > 其它

关于Handler.post(Runnable runnable)的解释

2012-03-21 21:42 190 查看
http://stackoverflow.com/questions/5316393/handler-looper-implementation-in-android

http://developer.android.com/reference/android/os/Handler.html#post(java.lang.Runnable)

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.

这里是指这个Runable会加入的消息队列当中,同时会在handler所在的线程上运行。

也就是说,post(Runnable runnable) 并没有开启新的线程,这时我们就要注意了,当我们在UI主线程当中这样处理大事件时不能用此方法开启线程,

而要使用

Thread thread = new Thread(runnable);
thread.start();


的方式开启线程。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: