/** * Marks the beginning of an I/O operation that might block indefinitely. * * <p>This method should be invoked in tandem with the {@link #end end} method, using a * <tt>try</tt> ... <tt>finally</tt> block as shown <a href="#be">above</a>, in order to * implement asynchronous closing and interruption for this channel. */ protected final void begin() { if (interruptor == null) { interruptor = new Interruptible() { public void interrupt(Thread target) { synchronized (closeLock) { if (!open) return; open = false; interrupted = target; try { AbstractInterruptibleChannel.this.implCloseChannel(); } catch (IOException x) { } } } }; } blockedOn(interruptor); Thread me = Thread.currentThread(); if (me.isInterrupted()) interruptor.interrupt(me); }