Java Soket Communication Summary of the difference and summary of bio NiO AIO

Source: Internet
Author: User

1 synchronization refers to the user process triggering IO operation and waiting or polling to see if the IO operation is ready to go to the streets to buy clothes, do it yourself, other things can not be done.
2 asynchronous asynchronous refers to the user process triggered IO operation began to do their own things, and when the IO operation has been completed will be the completion of the IO notification (asynchronous feature is notification) tell a friend the size of the appropriate clothes, size, color, let a friend entrusted to sell, and then you can do other things. (When using asynchronous Io, Java will delegate IO read-write to OS processing, which requires the data buffer address and size to be passed to the OS)
3 blocking the so-called blocking mode means that when trying to read and write to the file descriptor, if there is nothing to read, or temporarily not writable, the program enters the waiting state, until something can be read or can be written to the bus station recharge, found this time, the clerk is not (may go to the toilet), Then we wait here until the top clerk comes back. (Of course, the real world is not, but it is true in computers.) )
4 Non-blocking non-blocking state, if there is nothing to read, or not to write, read and write function immediately return, and do not wait, the bank in the withdrawal business, collect a small ticket, we can play mobile phone after the collection, or chat with others, when the wheel we, the bank's horn will be notified, this time we can go.

Java support for bio, NIO, AIO:
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.
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 on the multiplexer, and the multiplexer polls to the connection with an I/O request to start a thread for processing.
Java AIO (nio.2): Asynchronous non-blocking, server implementation mode for a valid request for a thread, the client I/O requests are completed by the OS before notifying the server application to start the thread for processing,

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 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.

In addition, I/O is the underlying operation, requires operating system support, concurrency also requires operating system support, so the performance of different operating system differences will be more obvious.

Java Soket Communication Summary of the difference and summary of bio NiO AIO

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.