tiancaiamao
深入解析Go

Updated 3 years ago

liguoqing (@pingworld) started discussion #41

a year ago · 2 comments

Open

编译器可以检测到16和18行是存在竞态条件的,也就是count并没像我们想要的那样在临界区执行。继续往下看,读完这一节,回头再来看就可以明白为什么这里有bug了。

内存模型 (Edit this file)

go version go1.11.5 linux/amd64,no race was detected.

And I have ran it on centos7 over 100000 times, there is no race(count != 0) occur.

liguoqing @pingworld commented a year ago

And I think it's different case from what listd in The Go Memory Model. Here I think ch <- true required happens before <- ch which is guaranteed by golang.

itfly @itfly commented 8 months ago

No data race found.


to join this conversation on GitBook. Already have an account? Sign in to comment
Notifications

You’re not receiving notifications from this thread.


2 participants