Process Vs Thread Vs Coroutine
| Process | Thread | Coroutine/eventloop | Goroutine/Virtual thread | |
|---|---|---|---|---|
| Difference | A process can have many thread | A thread can only belong to 1 process | For python/node js, coroutine only 1 thread (event loop). For other languages, look at goroutine/virtual thread | Can run in multiple thread |
| Memory | Different process DO NOT share memory if they're not forked from one another | Thread will share memory | Has a single event loop to coordinate between task (should not be blocked) | 1 OS thread can handle N virtual threads. Not limited by event loop |
| Concurrency | Different processes can have concurrency and parallelism | A Thread will allow concurrency and parallelism | Depends on the structure. But guarantee to have concurrency | High concurrency throughput |
Coroutine is like Event Queue (event loop) to execute concurrency.