标签:end spl zhang nbsp print span pack bool second
先看代码
package main import ( "strings" "fmt" "time" ) func main() { users:=strings.Split("shenyi,zhangsan,lisi,wangwu",",") ages:=strings.Split("19,21,25,26",",") c1,c2:=make(chan bool),make(chan bool) ret:=make([]string,0) go func() { for _,v:=range users{ <-c1 ret=append(ret,v) time.Sleep(time.Second) c2<-true } }() go func() { for _,v:=range ages{ <-c2 ret=append(ret,v) c1<-true } }() c1<-true fmt.Println(ret) }
打印:
[shenyi]
标签:end spl zhang nbsp print span pack bool second
原文地址:https://www.cnblogs.com/sunlong88/p/11234859.html