Use a metaphor to explain the understanding of synchronous asynchronous blocking non-blocking polling callbacks

Source: Internet
Author: User

When I was a sophomore looking at "thinking in Java" NIO, these concepts are very vague, now senior seniors graduating, see the "Tomcat authoritative guide" when you have to meet these concepts, this decision to understand it.

If they are directly from the Internet to get their definition, then I write this blog has no meaning, it is better to write a bunch of links it! And with a special definition explanation for a lot of people who use terminology to explain terminology, then they have to go on to the words that Google doesn't understand. So I think it is still with Mencius thought: with fish and Bear's paw to compare life and righteousness bar


For example, I bought a thing on the internet and waited for it to be sent to the Post office to fetch it. There are 4 of these cases:

    1. You stand at the Post office and wait for something.

    2. You keep doing what you have to do, not because there's a package that's going to affect your normal life.

    3. Something to send you a text message

    4. No one's telling you when you're in the mail.


    1. is blocked (because there will be parcels, you are specially waiting for parcels, the package is not you on the Post office Door Strike!),

    2. is non-blocking (not because there is a parcel you will affect your normal life and the work to do)

    3. is asynchronous (people are very dedicated to inform you)

    4. is the synchronization (the Big World in the black EMS mail heap into the mountains but not notify people to take this is the case)


Then the permutations and combinations, and these four things:

1. Synchronous blocking: The parcel came without notice to you, you just stood at the post office door waiting for the package.

2. Synchronous non-blocking (polling): You do what you do, although they do not inform you, but you occasionally run to the post office to ask me if the package is not. As you ask at noon or every hour, it's time to see how much ink you can get.

3. Asynchronous blocking: Although Lun will notify you by text message, but you have to stand at the post office to wait for the parcel. There is time, is so capricious! But I guess the program ape should have no one who would write such willful code?

4. Asynchronous non-blocking (callback): In fact, the first time I heard to wait outside the Post office mail I was refused, because, you can not let me put down all the work, I immediately go to the post office outside the mail ... Wait a while, cell phone, duang~~duang~~duang~~ my mail to the post office.


In short, async is used in non-blocking, because I have not seen who write asynchronous blocking program, if you are ruthless, then try to write an asynchronous blocking program feel it!


In fact, I was just trying to get a better understanding of the concepts of these terms, the loopholes that could be explained, and the great gods.







Use a metaphor to explain the understanding of synchronous asynchronous blocking non-blocking polling callbacks

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.