4 ms·
Goroutines are not threads: https://rcoh.me/posts/why-you-can-have-a-million-go-routines-but-only-1000-java-threads/ https://rcoh.me/posts/why-you-can-have-a-mi
by WoodenChair 8y ago
Goroutines are not threads:
https://rcoh.me/posts/why-you-can-have-a-million-go-routines-but-only-1000-java-threads/ https://rcoh.me/posts/why-you-can-have-a-million-go-routines...
- zzzcpan 8y agohttps://en.wikipedia.org/wiki/Thread_(computing)#M:N_(hybrid_threading) https://en.wikipedia.org/wiki/Thread_(computing)#M:N_(hybrid...
- giancarlostoro 8y agoGoroutines are probably closer to Fibers which D also has: https://en.wikipedia.org/wiki/Fiber_(computer_science) https://en.wikipedia.org/wiki/Fiber_(computer_science)
- zzzcpan 8y agoThey used to be closer to fibers years ago, when they were running on a single thread by default. Now they behave exactly like normal threads with the same problems. And fibers are threads anyway.
- giancarlostoro 8y agoCare to share a reference to them no longer being lightweight?
- zzzcpan 8y agoThey still start with tiny stacks, if that's what you are asking. I believe it's somewhere around 2 KB nowadays.
- hu3 8y agogoroutines are anything but threads. Here's a 40min talk explaining how Go's scheduler works: https://youtu.be/YHRO5WQGh0k https://youtu.be/YHRO5WQGh0k
- zzzcpan 8y agoNo, they are threads. It doesn't matter if they start with tiny growing stacks and whether blocking syscall wrappers call into the scheduler. Those are just implementation details.
- Groxx 8y agoI mean, sure, but they have all the same problems as threads for most / application-level developers. They're indeed quite different when you get into calling out to C or other kinds of FFI, but relatively few developers need to do so directly. For everyone else, they come with very nearly exactly the same semantics as threads.