-
- All Superinterfaces:
-
AutoCloseable,Channel,Closeable
- 所有已知实现类:
-
AbstractInterruptibleChannel,AbstractSelectableChannel,DatagramChannel,FileChannel,Pipe.SinkChannel,Pipe.SourceChannel,SctpChannel,SctpMultiChannel,SctpServerChannel,SelectableChannel,ServerSocketChannel,SocketChannel
public interface InterruptibleChannel extends Channel
可以异步关闭和中断的通道。实现此接口的通道是异步可关闭的:如果某个线程在可中断通道上的I / O操作中被阻塞,则另一个线程可能会调用该通道的
close方法。 这将导致被阻止的线程收到AsynchronousCloseException。实现此接口的通道也是可中断的:如果线程在可中断通道上的I / O操作中被阻塞,则另一个线程可能会调用被阻塞线程的
interrupt方法。 这将导致通道关闭,被阻塞的线程接收ClosedByInterruptException,并且阻塞线程的中断状态将被设置。如果线程的中断状态已经设置并且它在通道上调用阻塞I / O操作,则通道将关闭,线程将立即收到
ClosedByInterruptException; 其中断状态将保持设置状态。当且仅当它实现此接口时,通道才支持异步关闭和中断。 如有必要,可以通过
instanceof操作员在运行时对此进行测试。- 从以下版本开始:
- 1.4
-
-
方法详细信息
-
close
void close() throws IOException- Specified by:
-
close,接口AutoCloseable - Specified by:
-
close在界面Channel - Specified by:
-
close,界面Closeable - 异常
-
IOException- 如果发生I / O错误
-
-