Java I/O model and NIO parsing __java

Source: Internet
Author: User
1.Java IO Model parsing

Perhaps a lot of friends in the study of NiO will feel a little bit of difficulty, many of the concepts are not so clear. Before going into Java NIO programming, let's discuss some of the more basic knowledge today: I/O models. The following article starts with the concept of synchronous and asynchronous, then explains the difference between blocking and non-blocking, then introduces the difference between blocking IO and non-blocking io, then introduces the difference between synchronous IO and asynchronous Io, and then introduces 5 IO models, Finally, two design patterns (reactor and proactor) related to high performance IO design are introduced.

The following is a table of contents outline for this article:

One. What is synchronization. What is asynchronous.

Two. What is blocking. What is non-blocking.

Three. What is blocking IO. What is non-blocking IO.

Four. What is synchronous IO. What is asynchronous IO.

Five. Five kinds of IO models

Six. Two kinds of high-performance io design Patterns

  one. What is synchronization. What is asynchronous.

The concept of synchronous and asynchronous has been coming out for a long time, and there are many theories about synchronization and asynchrony on the Internet. The following is my personal understanding:

Synchronization is: If there are multiple tasks or events to occur, these tasks or events must be carried out one at a time, the execution of an event or task will cause the whole process to wait for a while, these events do not have the means to execute concurrently;

Asynchronous: If there are multiple tasks or events, these events can be executed concurrently, and the execution of an event or task will not cause the entire process to be temporarily waiting.

This is synchronous and asynchronous. To give a simple example, if you have a task that includes two subtasks A and B, for synchronization, when a is executed, B waits only until a completes, and B can execute concurrently, and for asynchronous is a and B to execute synchronously, B does not have to wait for a to execute before execution. This will not cause the entire task to wait temporarily because of a's execution.

If you do not understand, you can first look at the following 2 pieces of code:

1 2 3 4 5 6 7 8 9 10 11 12 13-14 void Fun1 () {} void Fun2 () {} void function () {fun1 ();

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.