Synchrony implies that the execution of multiple tasks occurs sequentially one after the other. Tasks are like steps that are executed in order, each operation blocks the others until completion.
Task #1 βββββββββββββ€............................
Task #2 .............ββββββββββββββ€..............
Task #3 ...........................ββββββββββββββ€
Asynchrony implies that the execution of multiple tasks may occur in some form of parallelism. Asynchrony is made possible through a program whose programming model allows operations to be executed in a non-blocking fashion. Asynchronous tasks are typically handled by a single-threaded event loop, which can offload these tasks to a thread pool.
Task #1 ββββββ...........ββββββββββββ€ (Core #1)
Task #2 ......ββββββ.....βββββ|...... (Core #2)
Task #3 ............βββββ......ββββββ€ (Core #2)
Task #4 ............βββββββββββββββββ€ (Core #3)
π» | Link |
---|---|
Node.js | https://nodejs.org/en/learn/asynchronous-work/event-loop-timers-and-nexttick |
Python | https://docs.python.org/library/asyncio-eventloop.html |
Concurrency implies that the execution of multiple tasks occurs within the same period. Tasks may overlap temporally, but they are not executed at the same instant. Simulated parallelism is made possible through the use of multiple threads; The operating system is responsible for scheduling the execution times by interrupting a running thread to assign CPU time to another thread (Context Switch).
Task #1 ββββββ......βββββ..................ββββββ€
Task #2 ......ββββββ...........ββββββ€............
Task #3 .................ββββββ......ββββββ€......
Simultaneity implies that the execution of multiple tasks occurs at exactly the same time. Real parallelism is made possible through the use of hardware with multiple CPU/GPU cores.
Task #1 βββββββββββββββββββββββββββββ€ (Core #1)
Task #2 βββββββββββββββββββββββββββββ€ (Core #2)
Task #3 βββββββββββββββββββββββββββββ€ (Core #3)