Code example for LinkedBlockingQueue

0
        private static class Entry { 
            public long mScheduledTime;
            public TimerTask mTask;
        } 
 
        private final BlockingQueue<Entry> mTasks = new LinkedBlockingQueue<Entry>();
 
        public MockTimer(Clock clock) {
            mClock = clock;
        } 
 
        @Override 
        public void schedule(TimerTask task, long delay) {
            if (delay == 0) {
                task.run();
            } else { 
                Entry e = new Entry();
                e.mScheduledTime = mClock.getTime() + delay;
                e.mTask = task;
                mTasks.offer(e);
            }