beegoDemo/beego_demo1/tests/test_chan/test_goroutline.go
2021-07-12 23:39:58 +08:00

24 lines
280 B
Go

package main
import "fmt"
var do = make(chan int)
var close = make(chan int)
func test() {
for i := 0; i < 100; i++ {
<-do
fmt.Println("子携程")
close <- 1
}
}
func main() {
go test()
for i := 0; i < 100; i++ {
do <- 1
fmt.Println("主携程")
<-close
}
}