4 ms·
The different types of lightweight threads and thread-like things can differ quite a bit in their implementation and usage. E.g. some are explicitly cooperativ
by beering 12y ago
The different types of lightweight threads and thread-like things can differ quite a bit in their implementation and usage.
E.g. some are explicitly cooperative and require the function to Yield() to other coroutines. Others, like goroutines (which are more like threads) automatically yield at certain points (e.g. I/O or function calls).
I think generally coroutines imply that the programmer handles more of the logic of when to switch tasks, while lightweight threads (in Go, Haskell, etc.) imply that there's more stuff "behind the scenes" to manage the concurrency for you like real OS threads. You may have lightweight threads that are multiplexed onto multiple OS threads, but you wouldn't have coroutines that are multiplexed onto multiple OS threads because coroutines implies no parallelism.