by naasking · 3y ago · 0 comments
I don't think efficiency has only one meaning. For instance, you can create millions of coroutines while you're limited to only thousands of threads. Doesn't that mean your program is making better use of your hardware and thus is more efficient?
But coroutines have overhead (so do threads). Your millions of coroutines might be worse than your thousands of threads in terms of making efficient use of the cpu cores your app or service has available.
Threads usually preallocate some stack space, while coroutines usually don't. But that isn't such a big deal.
Pthreads work differently, but historically kernel-mode cooperative threads were also popular at one time.
(We decided to not go there because cooperative parallelism sucks balls.)