Code example for Queue

Methods: offer

0
    // multiple events into the queue to be processed. 
    private static class CommandQueueImpl implements CommandQueue{ 
        private final Queue<MonkeyEvent> queuedEvents = new LinkedList<MonkeyEvent>();
 
        public void enqueueEvent(MonkeyEvent e) {
            queuedEvents.offer(e);
        } 
 
        /** 
         * Get the next queued event to excecute. 
         * 
         * @return the next event, or null if there aren't any more. 
         */ 
        public MonkeyEvent getNextQueuedEvent() { 
            return queuedEvents.poll();
        } 
    }; 
 
    // A holder class for a deferred return value. This allows us to defer returning the success of 
    // a call until a given event has occurred. 
    private static class DeferredReturn {