Application of Asynchronous Programming: When will Asynchronous Programming be Used

  golang, question

For example, in. net, when will await,async async be used? What are the benefits?

Can you remember an article in junior high school Chinese called “overall planning method”?

To put it simply, suppose the process of frying a tomato egg:
 1. Wash and cut tomatoes for 1 minute.
 2. Beat eggs for 2 minutes
 3. stir-fry for 2 minutes
 
 One person (single thread) needs to finish one piece at a time, and the final total takes 5 minutes.
 
 However, if two people started to wash and cut tomatoes and beat eggs separately, it would take 2 minutes to prepare them (eggs cost time) and another 2 minutes for one person to fry them, which took 4 minutes altogether.
 
 This is asynchronous multithreading, and the actual situation will save more time and cost than assumed.
 
 What about your CPU 8?  If there is no multithreading and asynchronous design in the code, one CPU will run and the other 7 CPUs will only be used as decoration.

Another practical asynchronous application is message pushing and so on. It takes 0.2 seconds to send one message to 1 million members on average. If one message is sent after another, when will this code go? I still have to look at the report of sending results! Asynchronous Message Queuing is a solution. Messages are stored in Message Queuing, and fast response statistics and processing reports (not paying attention to whether the messages are delivered for the time being). Your code is finished, and the task is finished! The rest will be left to the message team. 10 threads will send messages slowly, and the team will generate 100 threads to distribute. Right, look at the hardware configuration of your message server!