select()'ing on a Selector

  • Thread starter Christopher Benson-Manica
  • Start date
C

Christopher Benson-Manica

When select() returns, is it guaranteed that each key in the
selectedKeys set is truly ready for at least one of the operations in
its interest set? I have seen text suggesting that select() is a
hint, but I have seen nothing in Sun's documentation that suggests
that it is so.
 
E

EJP

Christopher said:
When select() returns, is it guaranteed that each key in the
selectedKeys set is truly ready for at least one of the operations in
its interest set? I have seen text suggesting that select() is a
hint, but I have seen nothing in Sun's documentation that suggests
that it is so.

It is possible that a selected key is actually invalid, and that should
be your first test. Apart from that I suppose it might theoretically be
possible under some combination of multithreaded operations for a
selected key to have no readyOps(). Using normal NIO programming
techniques you would never detect that anyway, as you would test each
key for each readyOp in turn, and any unready key would just be ignored.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top