protected void implCloseSelectableChannel() throws IOException {
   synchronized (stateLock) {
     if (state != ST_KILLED) nd.preClose(fd);
     long th = thread;
     if (th != 0) NativeThread.signal(th);
     if (!isRegistered()) kill();
   }
 }
 public void kill() throws IOException {
   synchronized (stateLock) {
     if (state == ST_KILLED) return;
     if (state == ST_UNINITIALIZED) {
       state = ST_KILLED;
       return;
     }
     assert !isOpen() && !isRegistered();
     nd.close(fd);
     state = ST_KILLED;
   }
 }
  protected void implCloseSelectableChannel() throws IOException {
    synchronized (stateLock) {
      if (state != ST_KILLED) nd.preClose(fd);
      ResourceManager.afterUdpClose();

      // if member of mulitcast group then invalidate all keys
      if (registry != null) registry.invalidateAll();

      long th;
      if ((th = readerThread) != 0) NativeThread.signal(th);
      if ((th = writerThread) != 0) NativeThread.signal(th);
      if (!isRegistered()) kill();
    }
  }