Netty (1)-IO evolution

IO Evolution

  From JDK1.0 to JDK1.3, Java's I / O class library is very primitive. Many concepts or interfaces in UNIX network programming are not reflected in the I / O class library, such as Pipe, Channel, Buffer, and Selector. When JDK1.4 was released in 2002, NIO was officially released. It has newly added a java.nio package, which provides a lot of APIs and class libraries for asynchronous I / O development. So far, Java's network programming has been greatly improved.

1. Before JDK1.4

  In earlier versions before Java 1.4, the IO supported by Java is what we usually refer to as IO-blocking IO. At this time, Java's support for IO is not perfect, high-performance servers are generally developed using c ++ and c language. The main problems of blocking IO are as follows:

  1. No data buffer, I / O performance problems;
  2. No Channel, only input stream and output stream;
  3. Synchronous blocking I / O communication usually causes the communication thread to be blocked for a long time during reading and writing, which greatly reduces performance;
  4. During high concurrent access, a large number of threads will be generated, increasing the pressure on the server;
  5. The supported character set is limited, and the hardware portability is not good.

2. The emergence of NIO

  JDK1.4 newly added the java.nio package, which greatly promoted the development and application of Java-based non-blocking programming. NIO provides many new classes and interfaces:

  1. Buffer classes such as ByteBuffer;
  2. Pipe Pipe;
  3. Channel, including ServerSocketChannel and Socketchannel;
  4. Multiplexer selector;
  5. Encoding and decoding capabilities of multiple character sets;
  6. File channel FileChannel.

3. The emergence of AIO

  On July 28, 2011, JDK1.7 was officially released. One of its major highlights is the upgrade of the original NIO class library, known as NIO2.0. NIO2.0 evolved from JSR.203, it mainly provides the following three improvements:

  1. Provide APIs that can obtain file attributes in batches. These APIs are platform-independent, and are not coupled with the characteristic file system. In addition, it also provides a standard file system SPI for various service providers to expand and implement;
  2. Provide AIO function, support file-based asynchronous I / O operations and asynchronous operations for network sockets;
  3. Complete the channel functions defined by JSR-51, including support for configuration and multicast datagrams.

This blog is a reading note, reference book: "Netty authoritative guide"

Please point out any mistakes, welcome to comment or private message exchange! Keep updating Java, Python and big data technology every day, please pay attention!

Published 64 original articles · Like 148 · Visitors 20,000+

Guess you like

Origin blog.csdn.net/Orange_minger/article/details/105072523