You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another incorrect idiom is busy waiting for a value, as in:
var a string
var done bool
func setup() {
a = "hello, world"
done = true
}
func main() {
go setup()
for !done {
}
print(a)
}
As before, there is no guarantee that, in main, observing the write to done implies observing the write to a, so this program could print an empty string too. Worse, there is no guarantee that the write to done will ever be observed by main, since there are no synchronization events between the two threads. The loop in main is not guaranteed to finish.
what is mean The loop in main is not guaranteed to finish?is only happens on single core cpu or all mulit core cpus.
I run test on it,the main is all always finish。
The text was updated successfully, but these errors were encountered:
nerored
changed the title
About Golang memory model-The loop in main is not guaranteed to finish.
doc: About Golang memory model-The loop in main is not guaranteed to finish.
Mar 4, 2020
"The loop in main is not guaranteed to finish" means exactly what is says.
Just because all of our current implementations of Go eventually exit this loop, doesn't mean that it is guaranteed to finish on all future implementations of Go.
You'll probably have better results asking questions like this in one of the forums listed at https://github.com/golang/go/wiki/Questions. Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
this code from https://golang.org/ref/mem#tmp_2
what is mean The loop in main is not guaranteed to finish?is only happens on single core cpu or all mulit core cpus.
I run test on it,the main is all always finish。
The text was updated successfully, but these errors were encountered: