Synchronization refers to a user process triggering an IO operation and waiting or polling to see if the IO operation is ready
Async is when a user process triggers an IO operation and then starts to do its own thing, and when the IO operation is complete, I get the IO completion notification.
Blocking and non-blocking is for the process to access the data at the time, according to the readiness of the IO operation to take a different way, white is a read or write operation function implementation, blocking mode read or write function will wait, but not blocking mode, read or write function will immediately return a status value.
, IO operations can be divided into 3 categories:
Synchronous blocking bio, synchronous non-blocking NIO, asynchronous non-blocking AIO
Synchronous blocking IO (JAVA BIO):
Synchronization and blocking, the server implementation mode for a connection to a thread, that is, the client has a connection request when the server needs to start a thread to process, if the connection does not do anything will cause unnecessary thread overhead, of course, can be improved through the thread pool mechanism.
Synchronous non-blocking IO (Java NIO): Synchronous non-blocking, the server implementation mode is a request for a thread, that is, the connection request sent by the client is registered to the multiplexer, and the multiplexer polls to the connection with an I/O request to start a thread for processing. The user process also needs to ask the IO operation to be ready from time to time, which requires the user process to keep asking.
(Java AIO (nio.2)) asynchronous non-blocking IO:
In this mode, the user process only needs to initiate an IO operation and then return immediately, after the actual completion of the IO operation, the application will get the IO operation to complete the notification, at this time the user process only need to process the data, do not need to do the actual IO read and write operations, Because the actual IO read or write operation has been completed by the kernel.
Bio is a thread that connects to one another.
NIO is a request for a thread.
AIO is a valid request for a thread.
BIO, NIO, AIO application Scenario analysis:
The bio method is suitable for a small and fixed number of connections, which requires a high level of server resources, and is limited to applications, JDK1.4 the only choice before, but the program is intuitive and easy to understand.
The NIO approach is suitable for architectures with a large number of connections and short (light-operated) connections, such as chat servers, which are limited to applications, and are more complex to program, and JDK1.4 begin to support.
AIO mode allows for a large number of connections and long-connected (re-operation) of the architecture, such as the album server, full call to the OS to participate in concurrent operations, programming more complex, JDK7 began to support
Bio,nio,aio