安卓Handler和Looper的假想

时间:2015-05-22 19:10:09   收藏:0   阅读:273
       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循环者从消息队列中拿到消息后进行处理

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!