logoalt Hacker News

Retr0idtoday at 9:53 AM2 repliesview on HN

Goroutines are not directly equivalent to threads.


Replies

quietbritishjimtoday at 11:48 AM

If 100 goroutines are handled by 10 threads, the effect on correctness is identical: any two can be running in parallel with each other (not just concurrently). From the point of view of this discussion, that's all that matters.

show 1 reply
IshKebabtoday at 10:11 AM

They used to not be, because they were cooperatively scheduled and threads can be preempted. But they added goroutine preemption in Go 1.14 so in practice there aren't really any significant differences to threads, at least in semantics. (At least as far as I remember; been a while since I wrote any Go.)

You can be pedantic and say they aren't technically threads but that doesn't really matter from a programming perspective.