初级会员
  • 第 23573 位会员
  • LLLLLLs
  • 2018-10-08 15:59:02
  • Offline
  • 20 5

最近发布的主题

    暂无

最近发布的文章

    暂无

最近分享的资源

    暂无

最近发布的项目

    暂无

最近的评论

  • func main() { var ( arra = []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} arrb = []string{"a", "b", "c", "d", "e", "f"} ok = make(chan bool, 1) num = make(chan bool, 1) letter = make(chan bool, 1) ) go printSlice(arra, num, letter, ok) go printSlice(arrb, letter, num, ok) num <- true <-ok var ctn = true for ctn { select { case <-ok: ctn = false case <-num: letter <- true case <-letter: num <- true } } } func printSlice(slice interface{}, in, out, ok chan bool) { value := reflect.ValueOf(slice) for i := 0; i < value.Len(); i++ { <-in fmt.Println(value.Index(i).Interface()) out <- true } ok <- true } ![659DD080-54D0-404b-A9B2-7CDB431908F4.png](https://static.studygolang.com/181204/f305b81897d3ca4b2c2e56b00d033564.png)
  • ![1%DBC}[~0H5QE9%[F])O(JI.png](https://static.studygolang.com/181008/140894948856c6e8b9f1dbc9c993084b.png)