Code example for ArrayDeque

0
    private volatile Status mStatus = Status.PENDING;
 
    private final AtomicBoolean mTaskInvoked = new AtomicBoolean();
 
    private static class SerialExecutor implements Executor {
        final ArrayDeque<Runnable> mTasks = new ArrayDeque<Runnable>();
        Runnable mActive;
 
        public synchronized void execute(final Runnable r) {
            mTasks.addFirst(new Runnable() {
                public void run() { 
                    try { 
                        r.run();
                    } finally { 
                        scheduleNext(); 
                    } 
                } 
            }); 
            if (mActive == null) {
                scheduleNext(); 
            }