# InterruptibleChannel

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary: [Methods](https://developer.android.com/reference/java/nio/channels/InterruptibleChannel#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/nio/channels/InterruptibleChannel#inhmethods)  

# InterruptibleChannel


`
public


interface
InterruptibleChannel
`


`


implements

`[Channel](https://developer.android.com/reference/java/nio/channels/Channel)`


`

|----------------------------------------|
| java.nio.channels.InterruptibleChannel |

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known indirect subclasses [AbstractInterruptibleChannel](https://developer.android.com/reference/java/nio/channels/spi/AbstractInterruptibleChannel), [AbstractSelectableChannel](https://developer.android.com/reference/java/nio/channels/spi/AbstractSelectableChannel), [DatagramChannel](https://developer.android.com/reference/java/nio/channels/DatagramChannel), [FileChannel](https://developer.android.com/reference/java/nio/channels/FileChannel), [Pipe.SinkChannel](https://developer.android.com/reference/java/nio/channels/Pipe.SinkChannel), [Pipe.SourceChannel](https://developer.android.com/reference/java/nio/channels/Pipe.SourceChannel), [SelectableChannel](https://developer.android.com/reference/java/nio/channels/SelectableChannel), [ServerSocketChannel](https://developer.android.com/reference/java/nio/channels/ServerSocketChannel), [SocketChannel](https://developer.android.com/reference/java/nio/channels/SocketChannel) |----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------| | [AbstractInterruptibleChannel](https://developer.android.com/reference/java/nio/channels/spi/AbstractInterruptibleChannel) | Base implementation class for interruptible channels.                                                                   | | [AbstractSelectableChannel](https://developer.android.com/reference/java/nio/channels/spi/AbstractSelectableChannel)       | Base implementation class for selectable channels.                                                                      | | [DatagramChannel](https://developer.android.com/reference/java/nio/channels/DatagramChannel)                               | A selectable channel for datagram-oriented sockets.                                                                     | | [FileChannel](https://developer.android.com/reference/java/nio/channels/FileChannel)                                       | A channel for reading, writing, mapping, and manipulating a file.                                                       | | [Pipe.SinkChannel](https://developer.android.com/reference/java/nio/channels/Pipe.SinkChannel)                             | A channel representing the writable end of a [Pipe](https://developer.android.com/reference/java/nio/channels/Pipe).    | | [Pipe.SourceChannel](https://developer.android.com/reference/java/nio/channels/Pipe.SourceChannel)                         | A channel representing the readable end of a [Pipe](https://developer.android.com/reference/java/nio/channels/Pipe).    | | [SelectableChannel](https://developer.android.com/reference/java/nio/channels/SelectableChannel)                           | A channel that can be multiplexed via a [Selector](https://developer.android.com/reference/java/nio/channels/Selector). | | [ServerSocketChannel](https://developer.android.com/reference/java/nio/channels/ServerSocketChannel)                       | A selectable channel for stream-oriented listening sockets.                                                             | | [SocketChannel](https://developer.android.com/reference/java/nio/channels/SocketChannel)                                   | A selectable channel for stream-oriented connecting sockets.                                                            | |

<br />

*** ** * ** ***

A channel that can be asynchronously closed and interrupted.

A channel that implements this interface is *asynchronously
closeable:* If a thread is blocked in an I/O operation on an
interruptible channel then another thread may invoke the channel's [close](https://developer.android.com/reference/java/nio/channels/InterruptibleChannel#close()) method. This will cause the blocked thread to receive an
[AsynchronousCloseException](https://developer.android.com/reference/java/nio/channels/AsynchronousCloseException).

A channel that implements this interface is also *interruptible:*
If a thread is blocked in an I/O operation on an interruptible channel then
another thread may invoke the blocked thread's [interrupt](https://developer.android.com/reference/java/lang/Thread#interrupt()) method. This will cause the channel to be closed, the blocked
thread to receive a [ClosedByInterruptException](https://developer.android.com/reference/java/nio/channels/ClosedByInterruptException), and the blocked
thread's interrupt status to be set.

If a thread's interrupt status is already set and it invokes a blocking
I/O operation upon a channel then the channel will be closed and the thread
will immediately receive a [ClosedByInterruptException](https://developer.android.com/reference/java/nio/channels/ClosedByInterruptException); its interrupt
status will remain set.

A channel supports asynchronous closing and interruption if, and only
if, it implements this interface. This can be tested at runtime, if
necessary, via the `instanceof` operator.

## Summary

|                                                               ### Public methods                                                               ||
|------------------|------------------------------------------------------------------------------------------------------------------------------|
| ` abstract void` | ` `[close](https://developer.android.com/reference/java/nio/channels/InterruptibleChannel#close())`() ` Closes this channel. |

| ### Inherited methods |
|-----------------------|---|
| From interface ` `[java.nio.channels.Channel](https://developer.android.com/reference/java/nio/channels/Channel)` ` |---------------------|-----------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void`    | ` `[close](https://developer.android.com/reference/java/nio/channels/Channel#close())`() ` Closes this channel.                         | | ` abstract boolean` | ` `[isOpen](https://developer.android.com/reference/java/nio/channels/Channel#isOpen())`() ` Tells whether or not this channel is open. | ||
| From interface ` `[java.io.Closeable](https://developer.android.com/reference/java/io/Closeable)` ` |------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](https://developer.android.com/reference/java/io/Closeable#close())`() ` Closes this stream and releases any system resources associated with it. | ||
| From interface ` `[java.lang.AutoCloseable](https://developer.android.com/reference/java/lang/AutoCloseable)` ` |------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](https://developer.android.com/reference/java/lang/AutoCloseable#close())`() ` Closes this resource, relinquishing any underlying resources. | ||

## Public methods

### close

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void close ()
```

Closes this channel.

Any thread currently blocked in an I/O operation upon this channel
will receive an [AsynchronousCloseException](https://developer.android.com/reference/java/nio/channels/AsynchronousCloseException).

This method otherwise behaves exactly as specified by the [Channel](https://developer.android.com/reference/java/nio/channels/Channel#close()) interface.

<br />

<br />

|                                               Throws                                               ||
|----------------------------------------------------------------------------|------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | If an I/O error occurs |