Interface InterruptibleChannel

All Superinterfaces:
AutoCloseable, Channel, Closeable
All Known Implementing Classes:
AbstractInterruptibleChannel, AbstractSelectableChannel, DatagramChannel, FileChannel, Pipe.SinkChannel, Pipe.SourceChannel, SelectableChannel, ServerSocketChannel, SocketChannel

public interface InterruptibleChannel
extends Channel
Channels that implement this interface can be asynchronously closed and interrupted.

A channel that can be asynchronously closed permits that a thread blocked on an I/O operation (the I/O thread) can be released by another thread calling the channel's close() method. The I/O thread will throw an AsynchronousCloseException and the channel will be closed.

A channel that is interruptible permits a thread blocked on an I/O operation (the I/O thread) to be interrupted by another thread (by invoking Thread.interrupt() on the I/O thread). When the I/O thread is interrupted it will throw a ClosedByInterruptException, it will have its interrupted status set and the channel will be closed. If the I/O thread attempts to make an I/O call with the interrupt status set the call will immediately fail with a ClosedByInterruptException.

  • Method Summary

    Modifier and Type Method Description
    void close()
    Closes the channel.

    Methods inherited from interface java.nio.channels.Channel

    isOpen
  • Method Details

    • close

      void close() throws IOException
      Closes the channel.

      Any threads that are blocked on I/O operations on this channel will be interrupted with an AsynchronousCloseException. Otherwise, this method behaves the same as defined in the Channel interface.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Channel
      Specified by:
      close in interface Closeable
      Throws:
      IOException - if an I/O error occurs while closing the channel.