We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在Go的内存顺序保证一节中,讲了一个通道关闭的例子,如下 下面是一个通道关闭的例子。在这个例子中,赋值语句k = 1的执行保证在赋值语句y = 1执行之前结束,但不能保证在赋值语句x = 1执行之前结束。
func f6() { var k, x, y int c := make(chan bool, 1) go func() { c <- true k = 1 close(c) }() go func() { <-c x = 1 <-c y = 1 }() }
我自己写了一遍跑了下 但是还是不能理解为什么 赋值语句k = 1的执行保证在赋值语句y = 1执行之前结束, 感觉
k = 1 close(c)
和
x = 1 <-c y = 1
这两部分的执行顺序完全不能确定啊 请教我谢谢
The text was updated successfully, but these errors were encountered:
微信上已解答。这里先关闭了。
Sorry, something went wrong.
No branches or pull requests
在Go的内存顺序保证一节中,讲了一个通道关闭的例子,如下
下面是一个通道关闭的例子。在这个例子中,赋值语句k = 1的执行保证在赋值语句y = 1执行之前结束,但不能保证在赋值语句x = 1执行之前结束。
我自己写了一遍跑了下 但是还是不能理解为什么 赋值语句k = 1的执行保证在赋值语句y = 1执行之前结束,
感觉
和
这两部分的执行顺序完全不能确定啊 请教我谢谢
The text was updated successfully, but these errors were encountered: