code: @Override
      @SuppressWarnings({ "PMD.EmptySynchronizedBlock", "PMD.EmptyCatchBlock",
          "PMD.AvoidCatchingThrowable" })
      public void run() {
          try {
              registerAsGenerator();
              while (!Thread.currentThread().isInterrupted()) {
                  try {
                      selector.select();
                      Set<SelectionKey> selected = selector.selectedKeys();
                      for (SelectionKey key : selected) {
                          ((NioHandler) key.attachment())
                              .handleOps(key.readyOps());
                      }
                      selected.clear();
                      synchronized (selectorGate) {
                          // Delay next iteration if another thread has the lock.
                          // "Find bugs" complains, but this is really okay.
                      }
                  } catch (InterruptedIOException | InterruptedException
                          | Error e) {
                      break;
                  } catch (Throwable e) {
                      // Ignore anything else, this loop is crucial.
                  }
              }
          } finally {
              unregisterAsGenerator();
          }
      }
docs: Invoked once by the thread associated with the dispatcher. Handles
  all events from the underlying {@link Selector}.