Skip to content

Commit 7356e55

Browse files
committed
add
1 parent ee8700d commit 7356e55

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

happens_before/three.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
var c = make(chan int, 10)
4+
var aaa string
5+
6+
func ff() {
7+
aaa = "hello, world"
8+
c <- 0
9+
}
10+
11+
//要让gorutine显示执行的话,使用channel作为同步信号,阻塞
12+
//The closing of a channel happens before a receive that returns a zero value because the channel is closed.
13+
func main() {
14+
go ff()
15+
<-c
16+
print(aaa)
17+
}

0 commit comments

Comments
 (0)