Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between Sequential and Synchronous Execution?

If I understand it correctly:

Asynchronous Execution - One task doesn't have to wait for another to finish

Concurrent Execution - Two tasks are being worked during a common time period (usually through context switching)

But the opposites of both of those seem the same.

Synchronous Execution - One task has to wait for another to finish before executing

Sequential Execution - Two tasks can't be worked on during a common time period. They have to be executed in order.

It seems Synchronous and Sequential execution are the same thing. What am I missing?

like image 490
master_of_privates Avatar asked Sep 20 '25 19:09

master_of_privates


2 Answers

Sequential and synchronous are different things. Lets take for example next pseudocode:

pseudocode

{

do A

do B

do C

}

both sequential and synchronous will do task in order A->B->C. The difference is in the way they can do it.

Only way synchronous can do it is to start executing task A, block everything and wait till the task is finished. After that it proceeds to task B. You can imagine this as execution of all tasks on one single thread.

On the other hand with sequential execution we can start execution of task A on thread 1 in background. After is finishes we can start executing task B on our main thread (lets say thread 2). We have same end result, but as you can see the process is different

For all intents and purposes, especially if you're a novice/junior programming, you should pretty much consider:

Sequential, synchronous, blocking, to be interchangeable terms.

Concurrent, asynchronous, non-blocking, to be interchangeable terms.

But asynchrony and parallelism are not synonyms at all, and while they both fall under the umbrella term of concurrency, they are very two different ways of achieving it.

like image 36
M.Ed Avatar answered Sep 23 '25 11:09

M.Ed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!