Handler实现与机制 && Blocking Queue && IdleHandler使用

http://blog.csdn.net/boyupeng/article/details/46685343

IdleHandler处理消息的源码

final Message next() {
         ...

        // Run the idle handlers.
            // We only ever reach this code block during the first iteration.
            for (int i = 0; i < pendingIdleHandlerCount; i++) {
                final IdleHandler idler = mPendingIdleHandlers[i];
                mPendingIdleHandlers[i] = null; // release the reference to the handler

                boolean keep = false;
                try {
                    keep = idler.queueIdle();
                } catch (Throwable t) {
                    Log.wtf("MessageQueue", "IdleHandler threw exception", t);
                }

                if (!keep) {
                    synchronized (this) {
                        mIdleHandlers.remove(idler);
                    }
                }
            }
}
原文地址:https://www.cnblogs.com/genggeng/p/7160646.html