Synchronous asynchronous, blocking non-blocking for I/o:
Blocking: The thread waits when the data required to perform the operation is not ready
Non-blocking: The thread does not wait when the data is not ready
Sync: Perform operations, wait until the operation is finished before performing down
Asynchronous: Performs an operation, does not wait for the interface to be invoked, executes down
the Common read () and write () methods are synchronous I/O.
of traditional I/O is a blocking type.
The problem is that when the data required for the operation is not ready, the thread waits until the data arrives.
in order to solve this problem, we have introduced NIO Concept: Synchronous non-blocking I/O.
NIO is equivalent to defining a scheduler selector, which registers all channel channels that implement communication with the selector, It dispatches the operation of each channel and realizes that the channel does not transmit in blocking.
Channel :
filechannel datagramchannel (UDP) socketchannel (TCP) , serversocketchannel (TCP)
These channels cover the UDP tcp network io io
buffer : (with three parameters, capacity Capacity position Span style= "font-family: Song body", upper bound limit )
  write mode, limit equals capacity ; Read mode, limit equals position
bytebuffer charbuffer DoubleBuffer floatbuffer intbuffer longbuffer , shortbuffer
these Buffer covers the Basic data Typesyou can send via IO: Byte, short, int, long, float, double , and Char.
Java NIO also has a mappedbytebuffer, which is used to represent memory-mapped files.
Selector (can be compared to a Scheduling tools)
Selector allows single-threaded processing of multiple Channel
The only interface for buffer objects that provide data to buffer or read buffer data .
1. Create selector,channel, set channel channel to non-blocking mode
2. bind The socket object to the channel
3. Register the channel with the selector
4. Call selector 's selectedkeys to check all channels if anything is needed to happen, and if something happens, return all the Channel object.
5. through the channel, read the data of the communication, read the buffer.
Java I/O summary (ii) NIO