I've recently run into a problem which boggled the mind. A selector would occasionally begin to always return instantly with 0 things selected, despite no code calling wakeup to cause it. I've found a little nook in the Sun forums where people have gathered to
discuss the problem. I've tried the Thread.sleep(50) workaround, but it doesn't seem to work all the time (or at least it doesn't show any signs of working after Thread.sleep(50) has been executed for 100 iterations). I even tried removing all calls to wakeup() from my code and using select(long) instead, but the problem didn't go away.
I've also tried reregistering all the keys on a new selector, but I either didn't do it properly or that doesn't help.
Does anyone know of a reliable workaround?