code: public final SelectionKey register(Selector sel, int ops,
                                         Object att)
          throws ClosedChannelException
      {
          synchronized (regLock) {
              if (!isOpen())
                  throw new ClosedChannelException();
              if ((ops & ~validOps()) != 0)
                  throw new IllegalArgumentException();
              if (blocking)
                  throw new IllegalBlockingModeException();
              SelectionKey k = findKey(sel);
              if (k != null) {
                  k.interestOps(ops);
                  k.attach(att);
              }
              if (k == null) {
                  // New registration
                  synchronized (keyLock) {
                      if (!isOpen())
                          throw new ClosedChannelException();
                      k = ((AbstractSelector)sel).register(this, ops, att);
                      addKey(k);
                  }
              }
              return k;
          }
      }
docs: Registers this channel with the given selector, returning a selection key.
  
  <p>  This method first verifies that this channel is open and that the
  given initial interest set is valid.
  
  <p> If this channel is already registered with the given selector then
  the selection key representing that registration is returned after
  setting its interest set to the given value.
  
  <p> Otherwise this channel has not yet been registered with the given
  selector, so the {@link AbstractSelector#register register} method of
  the selector is invoked while holding the appropriate locks.  The
  resulting key is added to this channel's key set before being returned.
  </p>
  
  @throws  ClosedSelectorException {@inheritDoc}
  
  @throws  IllegalBlockingModeException {@inheritDoc}
  
  @throws  IllegalSelectorException {@inheritDoc}
  
  @throws  CancelledKeyException {@inheritDoc}
  
  @throws  IllegalArgumentException {@inheritDoc}