}
for (SelectionKey key : selectedKeys) {
if (key.isValid()) {
Object attachment = key.attachment();
if (attachment instanceof HandlerAdapter) {
HandlerAdapter adapter =
(HandlerAdapter) attachment;
// caches some states in the adapter so that
// they can be restored when it is done
adapter.cacheOps();
// remove all interestOps to stop further
// selection on channel (will be restored by the
// adapter when it is done)
key.interestOps(0);
// run adapter by executor