title: Why Netty uses reference counting instead of just one ByteBuffer per connection when NIO is single-threaded?
body: <p>I am confused why Netty 5.0 makes you use reference counting for ByteBuffers. Isn't Java NIO supposed to be single-threaded, in other words, one selector thread for many connections? Each client needs its own  <code>ByteBuffer</code> and that's it, no pooling should be needed unless I am missing something.</p>
  
  <pre><code>@Override
  public void channelRead(ChannelHandlerContext ctx, Object msg) {
      ByteBuf m = (ByteBuf) msg; // (1)
      try {
          long currentTimeMillis = (m.readUnsignedInt() - 2208988800L) * 1000L;
          System.out.println(new Date(currentTimeMillis));
          ctx.close();
      } finally {
          m.release();
      }
  }
  </code></pre>
  
  <p>Source: <a href="http://netty.io/wiki/user-guide-for-5.x.html" rel="nofollow">http://netty.io/wiki/user-guide-for-5.x.html</a></p>