Home > Java > JavaBase > What is the difference between synchronous and asynchronous in java

What is the difference between synchronous and asynchronous in java

Release: 2019-12-06 16:43:55
Original
4920 people have browsed it

What is the difference between synchronous and asynchronous in java

1. Synchronization and asynchronous concepts: (Recommended: java video tutorial)

1. Synchronization: All operations must be completed before Return to user. In this way, the user waits online for too long, giving the user a stuck feeling (that is, when the system is being migrated, if you click Migrate, the interface will not move, but the program is still executing, giving the user a stuck feeling). In this case, the user cannot close the interface. If it is closed, the migration process will be interrupted.

2. Asynchronous: Put the user request into the message queue and feedback to the user. The system migration program has been started and you can close the browser. Then the program slowly writes to the database. This is asynchronous. But the user does not feel stuck and will tell you that the system has responded to your request. You can close the interface.

2. The interaction methods in Java are divided into two types: synchronous and asynchronous:

The same places:

are all interactive methods, and they all send requests.

Different places:

Synchronous interaction: refers to sending a request, you need to wait for the return, and then you can send the next request, there is a waiting process;

Asynchronous interaction: refers to sending a request without waiting for the return. The next request can be sent at any time, that is, there is no need to wait. Difference: One needs to wait, the other does not need to wait. In some cases, our project development will give priority to asynchronous interaction methods that do not require waiting.

For more java knowledge, please pay attention to the java basic tutorial column.

The above is the detailed content of What is the difference between synchronous and asynchronous in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template