The Asynchronous Channel API

  • Anghel Leonard


We’ve finally reached the most powerful feature introduced in NIO.2, the asynchronous channel API. As you’ll see in this chapter, the asynchronous I/O (AIO) Java 7 journey starts in the java.nio.channels.AsynchronousChannel interface, which extends a channel with asynchronous I/O operations support. This interface is implemented by three classes: AsynchronousFileChannel, AsynchronousSocketChannel, and AsynchronousServerSocketChannel. There is a fourth class, AsynchronousDatagramChannel, which was added in the Java 7 beta release and then removed in the Java 7 final release; at this writing, this class is not available, but it may appear in future Java 7 releases, so this chapter covers it in sufficient depth to make you aware of its purpose. These classes are similar in style to the NIO.2 channel APIs. In addition, there is an asynchronous channel named AsynchronousByteChannel that can read and write bytes and stands up as a subinterface of AsynchronousChannel (this subinterface is implemented by the AsynchronousSocketChannel class). Moreover, the new API introduces a class named AsynchronousChannelGroup, which presents the concept of an asynchronous channel group, in which each asynchronous channel belongs to a channel group (the default one or a specified one) that shares a pool of Java threads. These threads receive instructions to perform I/O events and they dispatch the results to the completion handlers. All the effort is for the purpose of handling the completion of initiated asynchronous I/O operations.


Local Address Incoming Connection Future Mode Future Form Thread Pool 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Anghel Leonard 2011

Authors and Affiliations

  • Anghel Leonard

There are no affiliations available

Personalised recommendations