Asynchronous vs synchronous execution, what does i

2018-12-31 01:16发布

What is the difference between asynchronous and synchronous execution?

21条回答
深知你不懂我心
2楼-- · 2018-12-31 01:46

Synchronous Programming model – A thread is assigned to one task and starts working on it. Once the task completes then it is available for the next task. In this model, it cannot leave the executing task in mid to take up another task. Let’s discuss how this model works in single and multi-threaded environments.

Single Threaded – If we have couple of tasks to be worked on and the current system provides just a single thread, then tasks are assigned to the thread one by one. It can be pictorially depicted as
Synchronous Single Threaded

Multi-Threaded – In this environment, we used to have multiple threads which can take up these tasks and start working on that. It means we have a pool of threads (new threads can also be created based on the requirement and available resources) and bunch of tasks. So these thread can work on these as
Synchronous Multi-Threaded

Asynchronous Programming Model – In contrary to Synchronous programming model, here a thread once start executing a task it can hold it in mid, save the current state and start executing another task.

Single Threaded Asynchronous Single Threade

Multi-Threaded Asynchronous Multi-Threaded

More here - https://codewala.net/2015/07/29/concurrency-vs-multi-threading-vs-asynchronous-programming-explained/

查看更多
浮光初槿花落
3楼-- · 2018-12-31 01:46

A synchronous operation does its work before returning to the caller.

An asynchronous operation does (most or all of) its work after returning to the caller.

查看更多
ら面具成の殇う
4楼-- · 2018-12-31 01:46

Synchronous means queue way execution one by one task will be executed. Suppose there is only vehicle that need to be share among friend to reach their destination one by one vehicle will be share.
In asynchronous case each friend can get rented vehicle and reach its destination.

查看更多
登录 后发表回答