SelectionKey实例调用interestOps(0)时的含义是什么?
SelectionKey实例调用interestOps(0)是什么意思? 0不是在SelectionKey中定义的枚举值。 interestOps(0)的功能是什么?SelectionKey实例调用interestOps(0)时的含义是什么?
回答:
有四种操作:OP_ACCEPT,OP_CONNECT,OP_READ和OP_WRITE。这些不是枚举值,它们是整型常量。如果您对多个操作感兴趣,则可以将这些值按位或运算在一起|。例如:
selectionKey.interestOps(SelectionKey.OP_READ | SelectionKey.OP_WRITE); interestOps(0)清除兴趣组,设置没有位。
如果那些常数为enum Operation值,那么interestOps(0)将变为interestOps(EnumSet.noneOf(Operation.class))。
回答:
SelectionKey实例调用interestOps(0)时的含义是什么?
这意味着这个选择键没有任何兴趣操作。 Selector.select()将忽略它。
0不是SelectionKey中定义的枚举值。
我不知道这是什么意思。在SelectionKey中没有定义枚举值。
interestOps(0)的功能是什么?
同样的问题,相同的答案。
以上是 SelectionKey实例调用interestOps(0)时的含义是什么? 的全部内容, 来源链接: utcz.com/qa/260943.html

