Code example for Queue

Methods: offer

    // 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) {
         * 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.