protected void accept_loop() { while (isRunning()) { try { SocketChannel client_channel = server_channel.accept(); last_accept_time = SystemTime.getCurrentTime(); client_channel.configureBlocking(false); listener.newConnectionAccepted(server_channel, client_channel); } catch (AsynchronousCloseException e) { /* is thrown when stop() is called */ } catch (Throwable t) { Debug.out(t); try { Thread.sleep(500); } catch (Exception e) { e.printStackTrace(); } } } }