public void run() { try { for (; ; ) { try { final Pair<Handler, Message> entry = eventQueue.take(); final Handler handler = entry.left; final Message message = entry.right; final Object result = message.accept(handler); if (message instanceof Command) { responseMap.put((Command) message, result); } else { // Broadcast the event to anyone who is interested. RolapUtil.MONITOR_LOGGER.debug(message); } if (message instanceof ShutdownCommand) { LOGGER.debug("ShutdownCommand received. Monitor thread is shutting down."); return; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); LOGGER.warn("Monitor thread interrupted.", e); return; } catch (Throwable t) { LOGGER.error("Runtime error on the monitor thread.", t); } } } finally { running = false; } }