public interface InterruptibleChannel extends Channel
一个通道,实现这个接口是异步闭合:如果一个线程在I/O操作在一个中断通道然后另一个线程可以调用通道的close
方法。这将导致阻塞的线程接收到一个AsynchronousCloseException
。
一个通道,实现了这个接口,也可中断:如果一个线程在I/O操作在一个中断通道然后另一个线程可以调用阻塞线程的interrupt
方法。这将导致通道被关闭,阻止的线程接收ClosedByInterruptException
,和阻止的线程的中断状态进行设置。
如果一个线程的中断状态已经设置并调用一个阻塞I/O操作在一个通道,然后通道将被关闭,线程会立即收到一ClosedByInterruptException
;中断状态将保持。
一个通道支持异步关闭和中断,如果,只有如果,它实现了这个接口。这可通过在运行时,如果有必要,通过instanceof算子。
void close() throws IOException
目前在任何线程阻塞I/O操作在这个通道将收到一AsynchronousCloseException
。
本法另有行为完全由Channel
指定界面。
close
接口
AutoCloseable
close
接口
Channel
close
接口
Closeable
IOException
如果I/O错误发生
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.