SelectableChannel « nio « Java I/O Q&A





1. How do I define my own SelectableChannel?    stackoverflow.com

How would I define a new type of java.nio.channels.SelectableChannel (say for serial ports)?

2. NIO Best Practices - SelectableChannel and InterestOps    stackoverflow.com

using java.nio one has to register interest in operations via the SelectableChannel:

SelectionKey = SelectableChannel.register(selector, interestInOpsBitmask)
Registering Interest:
  • overwriting the existing SelectionKey by executing SelectableChannel.register with new Ops
  • VS. updating the existing SelectionKey with key.interestOps(key.interestOps() ...