public void run() {
    try {
      serverChannel.register(nioSelector, SelectionKey.OP_ACCEPT);
      startupComplete();
      int currentProcessor = 0;
      while (isRunning()) {
        int ready = nioSelector.select(selectTimeOutMs);
        if (ready > 0) {
          Set<SelectionKey> keys = nioSelector.selectedKeys();
          Iterator<SelectionKey> iter = keys.iterator();
          while (iter.hasNext() && isRunning()) {
            SelectionKey key = null;
            try {
              key = iter.next();
              iter.remove();
              if (key.isAcceptable()) {
                accept(key, processors.get(currentProcessor));
              } else {
                throw new IllegalStateException("Unrecognized key state for acceptor thread.");
              }

              // round robin to the next processor thread
              currentProcessor = (currentProcessor + 1) % processors.size();
            } catch (Exception e) {
              key.cancel();
              metrics.acceptConnectionErrorCount.inc();
              logger.debug("Error in accepting new connection", e);
            }
          }
        }
      }
      logger.debug("Closing server socket and selector.");
      serverChannel.close();
      nioSelector.close();
      shutdownComplete();
      super.shutdown();
    } catch (Exception e) {
      metrics.acceptorShutDownErrorCount.inc();
      logger.error("Error during shutdown of acceptor thread", e);
    }
  }
Accept loop that checks for new connection attempts for a plain text port
ambry-network/src/main/java/com/github/ambry/network/SocketServer.java