public synchronized void execute(final Runnable r) { mTasks.offer( new Runnable() { public void run() { try { r.run(); } finally { scheduleNext(); } } }); if (mActive == null) { scheduleNext(); } }
protected synchronized void scheduleNext() { mActive = mReverse ? mTasks.pollLast() : mTasks.poll(); if (mActive != null) { THREAD_POOL_EXECUTOR.execute(mActive); } }