##### 为什么每次都能够执行成功?(go版本1.11,GOMAXPROCS 默认为CPU最大核数,即代码并行执行)
```golang
package main
import (
"fmt"
"time"
)
func main() {
arra := []int64{1,2,3,4}
arrb := []string{"a","b","c","d"}
c := make(chan bool)
go func(arra []int64) {
for i:=0;i < len(arra);i++ {
if flag := <-c;flag{
fmt.Println(arra[i])
c <- false
}
}
}(arra)
go func(arrb []string) {
for i:=0;i < len(arrb);i++ {
if flag := <- c;!flag{
fmt.Println(arrb[i])
c <- true
}
}
}(arrb)
c <- false
time.Sleep(time.Second * 2)
}
```
有疑问加站长微信联系(非本文作者)