Schema note [i]: synchronous vs. asynchronous

Source: Internet
Author: User
Tags apm

First Stage: Synchronization

All operations are executed in sequence, and the function is called before the next step is completed.

Phase II: Fully asynchronous

Problem: In a synchronous operation, some functions perform relatively time-consuming, resulting in reduced overall usability of the program and poor user experience.

Workaround: Perform the next step asynchronously, without waiting for the function to return. Wait until the function execution is triggered by some mechanism, so that the corresponding result to continue processing.

Phase three: Partially asynchronous

Issue: In full async, there may be situations where some operations can take too long, or an asynchronous function that has an error in execution that causes an inability to return normally. Causes the caller to consume some asynchronous trigger mechanism's resources, especially in the large-scale software, can cause the server performance to waste, the performance is reduced.

Workaround: Set the time to wait for an asynchronous operation by partially asynchronously, and if the timeout returns an error, release the resource for the asynchronous trigger mechanism.

Example: WCF

======================================

Asynchronous mechanism

Thought:

Another thread is started, which causes the master thread (usually the UI thread to be unblocked) to notify the result through inter-threading communication.

. NET:

Classification:

APM Mode (asynchronous programing model) other

EAP Mode (event-based Asynchronous Pattern) event-driven

Compare http://www.cnblogs.com/dctit/archive/2013/01/13/2853853.html

Example:

Apm:beginxxx/endxxx

Eap:xxxasync/xxxcomplete and Eventargs/eventhandler

In Java:

Asynctask; and other asynchronous implementations by threading

MessageQueue + Looper + Handler

NIO (New IO) Selector+socketchannel

Schema note [i]: synchronous vs. asynchronous

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.