public void run() { try { while (!stopped && !acceptSocket.socket().isClosed()) { try { select(); } catch (RuntimeException e) { LOG.warn("Ignoring unexpected runtime exception", e); } catch (Exception e) { LOG.warn("Ignoring unexpected exception", e); } } } finally { closeSelector(); // This will wake up the selector threads, and tell the // worker thread pool to begin shutdown. if (!reconfiguring) { NIOServerCnxnFactory.this.stop(); } LOG.info("accept thread exitted run method"); } }
public void stop() { stopped = true; // Stop queuing connection attempts try { ss.close(); } catch (IOException e) { LOG.warn("Error closing listen socket", e); } if (acceptThread != null) { if (acceptThread.isAlive()) { acceptThread.wakeupSelector(); } else { acceptThread.closeSelector(); } } if (expirerThread != null) { expirerThread.interrupt(); } for (SelectorThread thread : selectorThreads) { if (thread.isAlive()) { thread.wakeupSelector(); } else { thread.closeSelector(); } } if (workerPool != null) { workerPool.stop(); } }