Hacker News new | past | comments | ask | show | jobs | submit login

"thread" here refers to logical thread. A single logical thread can be used to run any number of goroutines, just one at a time.



Go does both preemptive and cooperative multitasking, so there is no relation to the number of goroutines "running" and the number of threads (or for that matter, cpus or cores).

https://en.wikipedia.org/wiki/Cooperative_multitasking

How this works in Go ? Thoroughly simplified it happens because at every flow control statement in Go, including function calls, what really happens is that, first, Go asks it's runtime to switch goroutines, and only then goes into the if, or subroutine, or ...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: