您如何使java.nio.channels.SelectionKey对 NO opts 感兴趣?
SelectionKey#cancel()有可能但不是很好,因为它使密钥无用。
SelectionKey有interestOps常数;OP_ACCEPT, OP_CONNECT,OP_READ和OP_WRITE, 但不是OP_NOTHING. 那么打电话合法SelectionKey#interestOpts(**0**)吗?
这是一个例子。
for(;;) {
    selector.select();
    for (Iterator<SelectionKey> it = selector.selectedKeys().iterator();
            it.hasNext();) {
        SelectionKey key = it.next(); it.remove();
        key.interestOps(0);     // interested in no opts.
        // another thread handles socket...
        worker.handle();
    }
    updateKeys();     // if the worker completes handling,
                      // other interestOpts are set...
}
到目前为止,此代码对我有用,但我怀疑调用SelectionKey#interestOpts(0). 或者你能告诉我你的最佳做法吗?