Synchronous, asynchronous, blocking, non-blocking understand

Aihe Cha Zhang, do not talk nonsense, boil water. 
Dramatis personae: Zhang, kettle two (ordinary kettle, referred kettle; will ring the kettle, kettle abbreviated ring). 
1 Zhang put the kettle on the fire, such as legislation to open water. (Synchronous blocking) 
Zhang felt a little silly 
2 Zhang put the kettle on the fire to the living room to watch TV from time to time to see if the kitchen is not open water. (Synchronous non-blocking) 
Zhang still felt a bit silly, so change high-end, bought a kettle that will ring the flute. After the water is boiling, it can emit a loud beep ~ ~ ~ ~ noise. 
3 Zhang put the kettle on the fire ring, legislation and other open water. (Asynchronous blocking) 
Zhang felt so little significance Shadeng 
4 Zhang put the kettle on the fire ring, to the living room watching TV, not to see it before the kettle rang, rang get another pot. (Asynchronous non-blocking) 
Zhang feel smart.

The so-called synchronous asynchronous, but for the purposes of the kettle. 
Ordinary kettle, synchronization; whistling kettle, asynchronous. 
Although able to work, but the whistling kettle may be completed after themselves, prompting Zhang open water. This is a common kettle can not reach. 
Synchronization can only let the caller go to polling own (case 2), resulting in low efficiency of Zhang.

The so-called blocking non-blocking, only for Zhang terms. 
Zhang Li, etc., obstruction; Zhang watching TV, non-blocking. 
In cases 1 and 3 is blocked Zhang, his wife did not know he shouted. While 3 in response kettle is asynchronous, it may not make much sense for the erecting of Zhang. Therefore, the general is in line with asynchronous non-blocking use, so as to play an asynchronous effectiveness.

Programmers write programs, in many cases, Zhang and kettle to be involved, that is, the caller and the callee. Four combinations of mode have their own strengths. 
This example and banks line up with the same purpose, but I think this would be more easier to understand. 
Zhang once again smarter than I like to admit with Zhang. The beginning of the case logic is relatively simple, but inefficient. With the improvement slowly, efficiency is improved. So I think, efficiency and simplicity of the program is inversely proportional. 
But not to say that non-blocking asynchronous necessarily the best, and in some cases more suitable for use synchronous or blocking.

Guess you like

Origin www.cnblogs.com/flamegreat/p/12195848.html