Java blocking asynchronous non-blocking synchronous understanding

Synchronous and asynchronous task scheduling by standing order to see whether the relationship between the tasks;

Operation with the task caller callers calling itself the task of operation is not the order of (synchronous) operation, this is the asynchronous operation invocation. Asynchronous operation behind the often multi-threaded (see language package size of the task).

Blocking and non-blocking is standing CPU perspective offers speed between (cpu and memory) and peripherals to match the understanding gap generated.

Blocking and non-blocking is standing on the point of view of the CPU. Computer running speed of each member are not the same, wherein the fastest CPU. Early CPU and memory speed is the same, does not require additional memory access wait, here the CPU and memory as internal computer system as a whole - on site. And other equipment - peripheral speed is very slow.
When participating in the next thing to do is not only in the computer will be able to deal directly with the site, you need to peripherals, CPU peripherals will be things to do. If the site shuffles wait peripheral processing is complete and return the results back before then to do things, this model is blocking mode , let the CPU, CPU performance is the sudden fall when the pressure measured; on the contrary CPU will do after to peripherals, offers directly behind not wait to do things, this model is a non-blocking mode . So the scene is blocking and non-blocking occurs when equipped with the interaction of the peripherals.
Interactive features and peripherals are often abstracted as IO, so blocking and non-blocking IO is almost always accompanied by the appearance (but not required).

Code level

Blocking: No callback; non-blocking, there is a callback;
synchronization: a single thread of execution; asynchronous, two threads of execution;

Here Insert Picture Description

For socket stream, the flow of data through two stages:

The first step usually involves waiting for data packet arrives on the network, then copied to a buffer core.
The second step to copy the data from the kernel buffer to buffer application process

Guess you like

Origin blog.csdn.net/liuqianduxin/article/details/84329979