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)