Closing the Selector when server is shutting down
问题 When I want to close the server, I will need to close Selector which is blocking the Thread. So, I call selector.close() from the main thread which helps to unblock selector.select(); But the selector doesn't throw ClosedSelectorException exception as it was supposed to I guess: while (true) { try { // Blocks until a 'socket' is ready registered with selector is ready. selector.select(); } catch (ClosedSelectorException ex) { // Never reached? ex.printStackTrace(); } catch (IOException ex) {