Processes Threads Coroutines Explained
Parallel = truly simultaneous on multi-core. Concurrent = fast switching on one core.
Processes: isolated memory, safer; heavier switches; IPC cost.
Threads: share memory; cheaper context switch; risk of race/deadlock.
Coroutines: user‑space scheduled lightweight threads; cooperative yielding.
Coroutine sample (PHP generator):
function echoTimes($msg, $max) { |
For multi-core combine multi-process + coroutine for throughput.
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
Comments