public interface Channel extends Closeable
Channels are open upon creation, and can be closed explicitly. Once a channel
is closed it cannot be re-opened, and any attempts to perform I/O operations
on the closed channel result in a ClosedChannelException.
Particular implementations or sub-interfaces of Channel dictate
whether they are thread-safe or not.
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes an open channel.
|
boolean |
isOpen()
Returns true if this channel is open.
|
boolean isOpen()
void close()
throws IOException
If an attempt is made to perform an operation on a closed channel then a
ClosedChannelException will be thrown on that attempt.
If multiple threads attempt to simultaneously close a channel, then only one thread will run the closure code, and others will be blocked until the first returns.
close in interface AutoCloseableclose in interface CloseableIOException - if a problem occurs closing the channel.