Selector.selectedKeys() random ordering vs. fairness
843790Aug 21 2007 — edited Aug 22 2007All Sun's selector implementations are based on SelectorImpl, which keeps selectedKeys in a classic HashSet with a random order of elements.
Now, suppose I insist on processing the incoming requests in the exact order as they were received, to ensure fairness. The classic mechanism for ensuring fairness are threads, but this a single-thread solution, and even with threads, it would be more fair to dispatch firstly-received requests first.
So far the only solution seems to be a dirty (should I say dodgy) replace (via reflection) of the aforementioned HashSet with a LinkedHashSet. (tested on Linux/epoll, works)
If you know of any other solution please let me know.