@Override public void cancel() { if (this.completed) { return; } this.completed = true; final SelectionKey key = this.key; if (key != null) { key.cancel(); final Channel channel = key.channel(); if (channel.isOpen()) { try { channel.close(); } catch (final IOException ignore) {} } } synchronized (this) { if (this.callback != null) { this.callback.cancelled(this); } notifyAll(); } }
@Override public void cancel() { if (this.completed) { return; } this.completed = true; final SelectionKey key = this.key; if (key != null) { key.cancel(); final Channel channel = key.channel(); if (channel.isOpen()) { try { channel.close(); } catch (final IOException ignore) {} } } synchronized (this) { if (this.callback != null) { this.callback.cancelled(this); } notifyAll(); } }