title: Alternative Java Selector Implementations
body: <p>I'm writing a high performance/low garbage application 
  (microseconds matter) that has a networking component.  One of the sore points that I've come across is the implementation of the built in Selector for Java NIO.</p>
  
  <p>A few things that are problematic:</p>
  
  <ul>
  <li>Lots of object creation.  Pretty much every call to selectedKeys() creates a lot of objects.  Iterators, boxing/unboxing, you name it.  Not a problem with most other cases but the application I'm writing needs to create as little garbage as possible.</li>
  <li>Layers upon layers of locking and synchronization.  At the time the selectorImpls were built, a bunch of the Java lock primitives didn't exist.  As a result it's clunky and not optimal.  In my use case, there's only one thread calling <code>select</code> so the locking is in fact useless.</li>
  </ul>
  
  <p>Extending or changing the selector implementation is a nonstarter.  Most of the classes are final, with private and package-private members located in the <code>sun.nio.ch.*</code> package.  Native methods also complicate things.</p>
  
  <p><strong>Are there any other more modern implementations of the selector that may be more performant?</strong></p>
  
  <p>The networking libraries I've examined just use the built in Java selector under the covers.  Any help would be appreciated.</p>