这样使用一个通道在两个例程之间交换数据是否可以?
c := make(chan int)
go func() {
var i int
select {
case c<- 1:
i = <-c
case i = <-c:
c<- 1
}
fmt.Println(" A - Written 1 red ", i)
}()
var i int
select {
case c<- 2:
i = <-c
case i = <-c:
c<- 2
}
fmt.Println(" B - Written 2 red ", i)
开心每一天1111
相关分类