这个类的作用是 在 主线程没有可处理的message(.next 无message handle时)
会去判断 是否有IdleHandler 如果有 则调用IdleHandler接口的实现方法
使用场景:性能优化 不影响主线程的任务处理 ,当主线程空闲下来时 执行 类似pendingTask
实际应用: 在LeakCanary 源码中有发现, 因为LeakCanary需要GC来确认是否存在内存泄漏
而GC会阻塞线程 使用该 IdleHandler去走 GC及其GC后的泄漏确认流程
另外Glide 中也用到了
源码:
/**
* Callback interface for discovering when a thread is going to block
* waiting for more messages.
*/
public static interface IdleHandler {
/**
* Called when the message queue has run out of messages and will now
* wait for more. Return true to keep your idle handler active, false
* to have i