Source:
<code>public final void run() { Thread selectorThread = Thread.currentThread(); String oldName = selectorThread.getName(); long cpuOverheatProtection = System.nanoTime(); try { while (isOpen()) { selectorThread.setName(getThreadNameBase(oldName)); try { processScheduledTasks(); boolean wantSelectNow = processRegistrations(); wantSelectNow = processInterestOps() || wantSelectNow; wantSelectNow = processSelectorTasks() || wantSelectNow; int selected; if (wantSelectNow) { selected = selector.selectNow(); } else { if (Launcher.isWindows()) { selected = selector.select(); } else { selected = selector.select(SELECTOR_WAKEUP_TIMEOUT_MS); } } if (selected == 0) { continue; } Set<SelectionKey> keys = selector.selectedKeys(); gen++; for (Iterator<SelectionKey> keyIterator = keys.iterator(); keyIterator.hasNext(); ) { SelectionKey key = keyIterator.next(); if (key.isValid()) { try { final int ops = key.readyOps(); key.interestOps(key.interestOps() & ~ops); final IOHubReadyListener listener = (IOHubReadyListener) key.attachment(); if (listener != null) { execute(new OnReady(_id, key, listener, ops)); } } catch (CancelledKeyException e) { } } keyIterator.remove(); } } catch (IOException e) { LOGGER.log(Level.WARNING, "Unexpected selector thread exception", e); long sleepNanos = System.nanoTime() - cpuOverheatProtection; if (sleepNanos > 0) { if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.log(Level.FINEST, "Sleeping for {0,number}ns to prevent selector thread CPU monopolization!", sleepNanos); } try { Thread.sleep(sleepNanos / 1000000L, (int) (sleepNanos % 1000000L)); } catch (InterruptedException e1) { } } else { cpuOverheatProtection = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(100); Thread.yield(); } } } } catch (ClosedSelectorException e) { } finally { selectorThread.setName(oldName); <START> ioHubRunning = false; <END> synchronized (winIoHubLockObject) { winIoHubLockObject.notifyAll(); } } }</code><technical_language>this point selector.isOpen() return false - get rid of this</technical_language>

Target:
public final void run() { Thread selectorThread = Thread.currentThread(); String oldName = selectorThread.getName(); long cpuOverheatProtection = System.nanoTime(); try { while (isOpen()) { selectorThread.setName(getThreadNameBase(oldName)); try { processScheduledTasks(); boolean wantSelectNow = processRegistrations(); wantSelectNow = processInterestOps() || wantSelectNow; wantSelectNow = processSelectorTasks() || wantSelectNow; int selected; if (wantSelectNow) { selected = selector.selectNow(); } else { selected = selector.select(); } if (selected == 0) { continue; } Set<SelectionKey> keys = selector.selectedKeys(); gen++; for (Iterator<SelectionKey> keyIterator = keys.iterator(); keyIterator.hasNext(); ) { SelectionKey key = keyIterator.next(); if (key.isValid()) { try { final int ops = key.readyOps(); key.interestOps(key.interestOps() & ~ops); final IOHubReadyListener listener = (IOHubReadyListener) key.attachment(); if (listener != null) { execute(new OnReady(_id, key, listener, ops)); } } catch (CancelledKeyException e) { } } keyIterator.remove(); } } catch (IOException e) { LOGGER.log(Level.WARNING, "Unexpected selector thread exception", e); long sleepNanos = System.nanoTime() - cpuOverheatProtection; if (sleepNanos > 0) { if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.log(Level.FINEST, "Sleeping for {0,number}ns to prevent selector thread CPU monopolization!", sleepNanos); } try { Thread.sleep(sleepNanos / 1000000L, (int) (sleepNanos % 1000000L)); } catch (InterruptedException e1) { } } else { cpuOverheatProtection = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(100); Thread.yield(); } } } } catch (ClosedSelectorException e) { } finally { selectorThread.setName(oldName); ioHubRunning = false; synchronized (selectorLockObject) { selectorLockObject.notifyAll(); } } }