A, IO migration path to the JAVA

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/yuan1164345228/article/details/94344977

1.1IO Basics

Java1.4 previous versions, support for the IO is not perfect, the main questions are as follows:

  • No data buffer, IO performance problems
  • No concept of C / C ++ in the Channel, and only the input and output streams
  • Only supports synchronous blocking IO (BIO), often lead to communication thread is blocked for a long time
  • Supported character sets is limited, not hardware portability

1.1.1 Linux network IO model profile

Unix provides five IO model:

  • Blocking IO model
  • Non-blocking IO model
  • IO multiplexing model
  • IO signal drive model
  • Asynchronous IO model

Since for java programmers, most of the time with less than a low-level details of network programming, linux network model this temporarily do in-depth research, and so do later used in the study.

1.1.2 IO multiplexing

In IO programming, when a server thread to handle multiple clients access requests, IO can be multithread or multiplexing techniques. IO multiplexing biggest advantage is the small system overhead, you do not need each connection creates a thread for processing.

Evolution of IO 1.2 JAVA

1) jdk1.0 to jdk1.3, only BIO

2) jdk1.4 new java.nio package that provides development API and NIO libraries, main classes and interfaces:

  • Asynchronous I / O operations and other buffers the ByteBuffer
  • Pipe conduit for asynchronous I / O operations
  • Various I / O (synchronous or asynchronous) of the Channel, and including ServerSocketChannel SocketChannel
  • Encoding and decoding capabilities ability multiple character sets
  • Non-blocking I / O operation of the multiplexer selector
  • Based on regular expressions library of popular Perl implementation
  • File channel FileChannel

3) jdk1.7 the original NIO library upgrades, major improvements in three aspects:

  • Provide a batch file attributes acquired API, which has a platform-independent, non-coupled with the profile system
  • AIO provides functionality to support file-based asynchronous I / O and asynchronous operation against a network socket
  • Complete channel features, including support for configuration and multicast datagrams

Guess you like

Origin blog.csdn.net/yuan1164345228/article/details/94344977