Java FAQ _01 Basic Concepts (014) _ Synchronous, asynchronous what is the difference

Source: Internet
Author: User

Click to enter _ more _java thousand ask

1. What is the difference between synchronous and asynchronous?

In network programming, we often see synchronous, asynchronous, blocking, non-blocking, four calls and their combinations.
Understanding blocking, non-blocking look here: [What is the difference between blocking and non-blocking][2]
[2]:

The synchronous mode, asynchronous mode is mainly controlled by the client, as follows:

Syncing (sync)

The so-called synchronization, that is, when a function call is issued, the call does not return or continue to perform subsequent operations until the result is obtained.
According to this definition, all methods in Java are synchronous calls and should be performed only after the results have been deferred. When we say synchronous, asynchronous, in general, it refers to tasks that require additional collaboration or time to complete.
Simply put, synchronization is one thing you have to do, and you can do the next thing before you finish it.

For example: b/S mode in the form submission, the specific process is: Client submission request, wait for server processing, processing completed return, in this process the client (browser) can not do other things.

Async (Async)

Asynchronous versus synchronous, when an asynchronous procedure call is issued, the caller can proceed with the subsequent operation until the result has been obtained. When this call is complete, the caller is generally notified by state, notification, and callback. For asynchronous calls, the return of the call is not controlled by the caller.
For the three ways to notify callers, the following is the case:

    1. State
      That is, listening to the status of the callee (polling), the caller needs to check every time, the efficiency will be very low.

    2. Notice
      When the callee executes, a notification informs the caller that there is no need to consume too much performance.

    3. Callback
      Similar to notifications, when the callee executes, it invokes the callback function provided by the caller.

For example: The AJAX request in B/S mode, the process is: Client issued AJAX request---server processing, processing completed client callback, after the client (browser) issued a request, still can do other things.

In summary, the difference between synchronous and asynchronous: After a request is issued, you need to wait for the result before you can continue with other operations.

Java FAQ _01 Basic Concepts (014) _ Synchronous, asynchronous what is the difference

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.