Processes vs. Threads vs. Coroutines#
Processes: Isolated, own memory, consists of one or many threads.
Threads: Minimal, manageable sequence of instructions.
Coroutines: Suspendable tasks executed by threads via cooperative multitasking.
Multi-threading allows to use idle-time of one thread for other operations
Analogy
The Process (The Workshop Facility) Isolated facility provisioned by the operating system. Memory space is encapsulated and strictly bounded.
The Threads (The Workers) Execution engines deployed within the facility. Shared access to identical resources is granted.
The Physical Cores (The Workstations) Hardware allocated by the central scheduler. Worker affinity can be strictly bound for execution reproducibility.
The Coroutines (The Suspendable Projects) Discrete projects managed via cooperative multitasking. Execution is suspended during I/O latency to allow reallocation of worker effort.