首页 > 移动平台 > 详细

安卓Handler和Looper的假想

时间:2015-05-22 19:10:09      阅读:273      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!