码迷,mamicode.com
首页 > 移动开发 > 详细

安卓Handler和Looper的假想

时间:2015-05-22 19:11:05      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

       if (Looper.myLooper() != Looper.getMainLooper()) {
                // If we finish marking off of the main thread, we need to
                // actually do it on the main thread to ensure correct ordering.
                Handler mainThread = new Handler(Looper.getMainLooper());
                mainThread.post(new Runnable() {
                    @Override
                    public void run() {
                        mEventLog.add(tag, threadId);
                        mEventLog.finish(this.toString());
                    }
                });
                return;

            }


handler里面持有一个Looper,Looper里面持有一个消息队列MessageQueue

handler首先会把消息Post到它所持有的Looper的消息队列之中,

Looper循环者从消息队列中拿到消息后进行处理

安卓Handler和Looper的假想

标签:

原文地址:http://blog.csdn.net/rnzuozuo/article/details/45920329

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!