3 ms·
> Goroutines all run in the same thread Rob Pike's presentation says something quite different. It says that gccgo "allocates one goroutine per thread" and th
by jgrahamc 17y ago
> Goroutines all run in the same thread
Rob Pike's presentation says something quite different. It says that gccgo "allocates one goroutine per thread" and that 6g has "good goroutine support, muxes them onto threads".
The language FAQ says:
"Goroutines are part of making concurrency easy to use. The idea, which has been around for a while, is to multiplex independently executing functions—coroutines, really—onto a set of threads. When a coroutine blocks, such as by calling a blocking system call, the run-time automatically moves other coroutines on the same operating system thread to a different, runnable thread so they won't be blocked. The programmer sees none of this, which is the point. The result, which we call goroutines, can be very cheap: unless they spend a lot of time in long-running system calls, they cost little more than the memory for the stack. "
- scott_s 17y agoI think he meant to say that goroutines all run in the same process - they share an address space.