protected void implClose() throws IOException { synchronized (closeLock) { if (closed) return; closed = true; // Deregister channels for (int i = channelOffset; i < totalChannels; i++) { SelectionKeyImpl ski = channelArray[i]; assert (ski.getIndex() != -1); ski.setIndex(-1); deregister(ski); SelectableChannel selch = channelArray[i].channel(); if (!selch.isOpen() && !selch.isRegistered()) ((SelChImpl) selch).kill(); } implCloseInterrupt(); pollWrapper.free(); pollWrapper = null; selectedKeys = null; channelArray = null; totalChannels = 0; } }