关于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主线程当中这样处理大事件时不能用此方法开启线程,
而要使用
的方式开启线程。
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();
的方式开启线程。
相关文章推荐
- 关于Handler.post(Runnable runnable)的解释
- 关于handler.post(Runnable runnable)
- 关于Handler.post(Runnable)
- Android从源码分析handler.post(runnable),view.post(runnable),runOnUiThread(runnable)执行时机
- Android开发中更新UI时runOnUIthread(Runnable)与Handler.post(Runnable)的区别及如何选择
- 从Handler.post(Runnable r)再一次梳理Android的消息机制(以及handler的内存泄露)
- handler.post(Runnable r) 会阻塞UI线程。
- handler.post方法的终极最直观的理解与解释
- 【Android】从Handler.post(Runnable r)再一次梳理Android的消息机制(以及handler的内存泄露)
- Handler.post(runnable)内更新UI
- Handler.post(Runnable runnable)中的Runnable对象去哪里了?
- handler.post方法的终极最直观的理解与解释
- Android使用异步的误区(关于Handler.post的操作方式)
- 从Handler.post(Runnable r)再一次梳理Android的消息机制(以及handler的内存泄露)
- Handler发送sendMessage和postRunnable的区别
- Handler post runnable
- 关于Handler的Post和Message的两种方法
- 从Handler.post(Runnable r)再一次梳理Android的消息机制(以及handler的内存泄露)
- 从Handler.post(Runnable r)再一次梳理Android的消息机制(以及handler的内存泄露)
- Message,MessageQueue,Looper,Handler ——由view.post(runnable想到的)