title: how to design and implement a "timeout Timer" in network programming, using java nio
body: <p>I'm using Java NIO to implement a server.</p>
  
  <p>For example, I will hold more than 10K connection. If the client did not send any data within 30 seconds, the server will kick off this client.</p>
  
  <p>How to design such Timeout Timer efficiently?</p>
  
  <p>My first thought was:</p>
  
  <ol>
  <li>accept a connection from client.</li>
  <li>put this connection into a list, along with a timestamp which indicate the last active time.</li>
  <li>using Executors.newFixedSizeSchedulePool to schedule a worker every 30 seconds.</li>
  <li>this worker will iterate over the list to find the connection which is inactive for more than 30 seconds.</li>
  </ol>
  
  <p>This is fine for small amount of connections. But, what if the size of connection queue increases? Will this solution still fit for 50K connections or more connections? </p>