Package jdk.nio

Interface Channels.SelectableChannelCloser

Enclosing class:

public static interface Channels.SelectableChannelCloser
An object used to coordinate the closing of a selectable channel created by readWriteSelectableChannel.
  • Method Details

    • implCloseChannel

      void implCloseChannel(SelectableChannel sc) throws IOException
      Closes a selectable channel.

      This method is invoked by the channel's close method in order to perform the actual work of closing the channel. This method is only invoked if the channel has not yet been closed, and it is never invoked more than once by the channel's close implementation.

      An implementation of this method must arrange for any other thread that is blocked in an I/O operation upon the channel to return immediately, either by throwing an exception or by returning normally. If the channel is registered with one or more Selectors then the file descriptor should not be released until the implReleaseChannel method is invoked.

      sc - The selectable channel
      IOException - If an I/O error occurs while closing the file descriptor
      See Also:
    • implReleaseChannel

      void implReleaseChannel(SelectableChannel sc) throws IOException
      Release the file descriptor and any resources for a selectable channel that closed while registered with one or more Selectors.

      This method is for cases where a channel is closed when registered with one or more Selectors. A channel may remain registered for some time after it is closed. This method is invoked when the channel is eventually deregistered from the last Selector that it was registered with. It is invoked at most once.

      API Note:
      This method is invoked while synchronized on the selector and its selected-key set. Great care must be taken to avoid deadlocks with other threads that also synchronize on these objects.
      sc - The closed selectable channel
      IOException - If an I/O error occurs
      See Also: