void sync(UiKitSyncPost post) { Queue var2 = this.mSyncPool; synchronized(this.mSyncPool) { this.mSyncPool.offer(post); //想Runable队列里添加一个任务 if(!this.isSyncActive) { this.isSyncActive = true; if(!this.sendMessage(this.obtainMessage(2))) { throw new RuntimeException("Could not send handler message"); } } } }
public void handleMessage(Message msg) { boolean rescheduled; long started; Queue timeInMethod; long timeInMethod1; if(msg.what == 1) { rescheduled = false; try { started = SystemClock.uptimeMillis(); do { Runnable post1 = this.poolAsyncPost(); //取出位于队列顶部的任务 if(post1 == null) { timeInMethod = this.mAsyncPool; synchronized(this.mAsyncPool) { post1 = this.poolAsyncPost(); if(post1 == null) { this.isAsyncActive = false; return; } } } post1.run(); timeInMethod1 = SystemClock.uptimeMillis() - started; } while(timeInMethod1 < (long)this.mMaxMillisInsideHandleMessage); if(!this.sendMessage(this.obtainMessage(1))) { throw new RuntimeException("Could not send handler message"); } else { rescheduled = true; } } finally { this.isAsyncActive = rescheduled; } } }