An asynchronous channel group encapsulates the mechanics required to handle the completion of I/O operations initiated by {@link AsynchronousChannel asynchronous channels} that are bound to thegroup. A group is created with an {@link ExecutorService} to which tasksare submitted to handle I/O events and dispatch to {@link CompletionHandler completion handlers} that consume the result ofasynchronous operations performed on channels in the group.
An asynchronous channel group is created by invoking the {@link #open}method. Channels are bound to a group by specifying the group when the channel is constructed. If a group is not specified then the channel is bound to a default group that is constructed automatically. The executor for the default group is created by invoking the {@link ThreadPoolFactory#newThreadPool() newThreadPool} method on a{@link ThreadPoolFactory} located as follows:
The {@link #shutdownNow} method can be used to initiate aforceful shutdown of the group. In addition to the actions performed by an orderly shutdown, the {@code shutdownNow} method closesall open channels in the group as if by invoking the {@link AsynchronousChannel#close close} method. A group will typicallyterminate quickly after the {@code shutdownNow} method has been invoked. @see AsynchronousSocketChannel#open(AsynchronousChannelGroup) @see AsynchronousServerSocketChannel#open(AsynchronousChannelGroup) @see AsynchronousDatagramChannel#open(ProtocolFamily,AsynchronousChannelGroup)
|
|
|
|