0
NIOでJavaセレクタを使用しています。選択キー/関心キーを特定のチャンネルとセレクタに登録しています。今、私の必要条件は、特定のセレクターに対して2つ以上の関心セットを持つことです。複数のSelectionKeyを登録する
try {
Selector selector = Selector.open();
ServerSocketChannel channel = ServerSocketChannel.open();
//FileChannel channel = new FileInputStream("").getChannel();
channel.configureBlocking(false);
SelectionKey key1 = channel.register(selector, SelectionKey.OP_READ);
SelectionKey key2 = channel.register(selector, SelectionKey.OP_WRITE);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
私の質問があり、私は2つの切り抜いたキーを避けることができますどのような方法があります:私は何
は、次のようにさまざまな選択オプションを持つ2つのselectionkeysを作るのですか?
より一般的な名前は、「ビット単位-か」https://en.wikipedia.org/wiki/Bitwise_operation#ORです –