24 lines
280 B
Go
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
|
|
}
|
|
|
|
}
|