在NIO中设置 SelectionKey.interestOps()无效
如下的代码中,设置了OP_WRITE是成功的
if(key.isReadable()){
SocketChannel readSocketChannel = (SocketChannel)key.channel();
readSocketChannel.configureBlocking(false);
Task task = new SocketTask(readSocketChannel);
key.interestOps(SelectionKey.OP_WRITE);
Future<TaskStatus> future = pool.submit(task);
但是如果我把
key.interestOps(SelectionKey.OP_WRITE);
放到线程中,就是那个执行task的线程,就不生效,为什么?? NIO selector
补充:Java , Java SE