Source:
public void doEventLoop() throws IOException, UnhandledEvent { this.thread_id = Thread.currentThread().getId(); while (!shouldStop) { long nextTimerEvent; int nEvents; List<FVEvent> tmpQueue = null; long startCounter; synchronized (eventQueue) { if (!eventQueue.isEmpty()) { FVLog.log(LogLevel.DEBUG,null,"EventQueue is not empty!"); tmpQueue = eventQueue; eventQueue = new LinkedList<FVEvent>(); } } if (tmpQueue != null) for (FVEvent e : tmpQueue) { startCounter = System.currentTimeMillis(); e.getDst().handleEvent(e); FVEventUtils.starvationTest(startCounter, e.getDst(), e); } nextTimerEvent = this.fvtimer.processEvent(); int ops; FVEventHandler handler; for (SelectionKey sk : selector.keys()) { ops = 0; if (!sk.isValid()) continue; handler = (FVEventHandler) sk.attachment(); if (handler.needsRead()) ops |= SelectionKey.OP_READ; if (handler.needsWrite()) ops |= SelectionKey.OP_WRITE; if (handler.needsConnect()) ops |= SelectionKey.OP_CONNECT; if (handler.needsAccept()) ops |= SelectionKey.OP_ACCEPT; sk.interestOps(ops); } FVLog.log(LogLevel.DEBUG, null, "calling select with timeout=", nextTimerEvent); nEvents = selector.select(nextTimerEvent); if (nEvents > 0) { for (SelectionKey sk : selector.selectedKeys()) { if (sk.isValid()) { handler = (FVEventHandler) sk.attachment(); FVLog.log(LogLevel.DEBUG, null, "sending IO Event= ", sk.readyOps(), " to ", handler.getName()); startCounter = System.currentTimeMillis(); FVIOEvent ioEvent = new FVIOEvent(sk, null, handler); handler.handleEvent(ioEvent); FVEventUtils.starvationTest(startCounter, handler, ioEvent); } } selector.selectedKeys().clear(); } } }

Target:
public void doEventLoop() throws IOException, UnhandledEvent { this.thread_id = Thread.currentThread().getId(); while (!shouldStop) { long nextTimerEvent; int nEvents; List<FVEvent> tmpQueue = null; long startCounter; synchronized (eventQueue) { if (!eventQueue.isEmpty()) { logger.debug("EventQueue is not empty!"); tmpQueue = eventQueue; eventQueue = new LinkedList<FVEvent>(); } } if (tmpQueue != null) for (FVEvent e : tmpQueue) { startCounter = System.currentTimeMillis(); e.getDst().handleEvent(e); FVEventUtils.starvationTest(startCounter, e.getDst(), e); } nextTimerEvent = this.fvtimer.processEvent(); int ops; FVEventHandler handler; for (SelectionKey sk : selector.keys()) { ops = 0; if (!sk.isValid()) continue; handler = (FVEventHandler) sk.attachment(); if (handler.needsRead()) ops |= SelectionKey.OP_READ; if (handler.needsWrite()) ops |= SelectionKey.OP_WRITE; if (handler.needsConnect()) ops |= SelectionKey.OP_CONNECT; if (handler.needsAccept()) ops |= SelectionKey.OP_ACCEPT; sk.interestOps(ops); } logger.debug("calling select with timeout = {}", nextTimerEvent); nEvents = selector.select(nextTimerEvent); if (nEvents > 0) { for (SelectionKey sk : selector.selectedKeys()) { if (sk.isValid()) { handler = (FVEventHandler) sk.attachment(); logger.debug("sending IO Event= to {}", sk.readyOps(), handler.getName()); startCounter = System.currentTimeMillis(); FVIOEvent ioEvent = new FVIOEvent(sk, null, handler); handler.handleEvent(ioEvent); FVEventUtils.starvationTest(startCounter, handler, ioEvent); } } selector.selectedKeys().clear(); } } }