The understanding of synchronous and asynchronous in C language

Source: Internet
Author: User

Now I'm in main.c this file, call 360 browser.

650) this.width=650; "src=" http://p1.pstatp.com/large/2429000031c0bc20e807 "alt=" C language synchronous and asynchronous understanding of "style=" Border-style : none;margin:10px auto; "/>

Analysis process: In the My.exe continue to open another program, so it is related to: My.exe continue to execute whether to wait for the other program to execute after the execution? If you want to wait, it's synchronous; If you don't wait, it's asynchronous. This is the problem of synchronous and asynchronous.

Now is the situation to wait:

The result is to wait until the browser is completely open to print Nihao.

If you look at it this way, it will be clearer:

650) this.width=650; "src=" http://p3.pstatp.com/large/22d700053034416a49b9 "alt=" C language synchronous and asynchronous understanding of "style=" Border-style : none;margin:10px auto; "/>

The result is:

One to open, and the last to print Nihao

650) this.width=650; "src=" http://p3.pstatp.com/large/22d800037755be53f928 "alt=" C language synchronous and asynchronous understanding of "style=" Border-style : none;margin:10px auto; "/>

If you want to asynchronously:

650) this.width=650; "src=" http://p3.pstatp.com/large/242800033dda773d9328 "alt=" C language synchronous and asynchronous understanding of "style=" Border-style : none;margin:10px auto; "/>

The result is:

650) this.width=650; "src=" Http://p1.pstatp.com/large/22d2000536ba4dc8bb22 "alt=" C language synchronous and asynchronous understanding of "style=" Border-style : none;margin:10px auto; "/>

Three browsers open almost simultaneously, and "Nihao" is printed first.

Because their order of execution is tied, who is lighter and who is fast. This is asynchronous.

At the same time you can see: The default is synchronous.

Summarize:

Synchronization: Is serial execution (in order, a wait), because it is the function of the call principle, the stack mechanism of advanced after the decision, slow, but save resources.

Asynchronous: Is parallel execution (no order, at the same time do), it uses the way to open multi-threaded to achieve at the same time, faster, but will increase the cost of resources;

The two should be used according to the application situation.

In fact, there are many applications of synchronous and asynchronous, such as: The digital circuit has synchronous circuit and asynchronous circuit. The Ajax used in the front and back of the Internet domain also has synchronous and asynchronous points. So synchronous and asynchronous is an important part of learning C language in depth.


This article is from the "C Language good cool" blog, please be sure to keep this source http://ningcaichen66.blog.51cto.com/2902291/1963982

The understanding of synchronous and asynchronous in C language

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.