Code example for ArrayDeque

0
	private final AtomicBoolean mTaskInvoked = new AtomicBoolean();
 
	@TargetApi(11) 
	private static class SerialExecutor implements Executor
	{ 
		final ArrayDeque<Runnable> mTasks = new ArrayDeque<Runnable>();
		Runnable mActive;
 
		public synchronized void execute(final Runnable r)
		{ 
			mTasks.offer(new Runnable()
			{ 
				public void run() 
				{ 
					try 
					{ 
						r.run();
					} finally 
					{ 
						scheduleNext(); 
					}