title: is socketChannel.register() synchronized with close() method in java NIO?
body: <p>In openJDK(jdk-6u23)this implementation of AbstractSelectableChannel.register() just like below:   </p>
  
  <p>it first checks whether this channel is open or not.and then do the register work with reg lock.but if we invoke the close method between the isOpen() test and synchronized block,the channel will be closed.then we will register a CLOSED channel with a selector... But is this right?</p>
  
  <pre><code>public final SelectionKey register(Selector sel, int ops,
                     Object att)
  throws ClosedChannelException
  {
  if (!isOpen())
      throw new ClosedChannelException();
  if ((ops &amp; ~validOps()) != 0)
      throw new IllegalArgumentException();
  synchronized (regLock) {
      if (blocking)
      throw new IllegalBlockingModeException();
      SelectionKey k = findKey(sel);
          if (k != null) {
              k.interestOps(ops);
      k.attach(att);
          }
      if (k == null) {
      // New registration
      k = ((AbstractSelector)sel).register(this, ops, att);
      addKey(k);
      }
          return k;
      }
  }
  </code></pre>