初级会员
  • 第 3418 位会员
  • ikaros
  • lucifer4he@gmail.com
  • 2015-08-27 05:24:27
  • Offline
  • 0

最近发布的主题

    暂无

最近发布的文章

    暂无

最近分享的资源

    暂无

最近发布的项目

    暂无

最近的评论

  • 评论了主题 go channel puzzle
    for the print order. when you use goroutine,it's hard to say which goroutine will finish first. that's why sometime we use channel to make few goroutine in a order. you can use more goroutine in your test4 and run it few time ,then you can see order not always the same here a example use channel as lock ``` package main import ( "fmt" "time" ) var c1 chan int func step1() { fmt.Println("step 1") c1 <- 1 } func step2() { <-c1 fmt.Println("step 2") } func main() { c1 = make(chan int) go step2() go step1() time.Sleep(10) } ```
  • 评论了主题 go channel puzzle
    it's like a queue. `arr1 := make(chan string)` you can put max one member into this chan,in order to push another one ,you should pop it first! `arr2 := make(chan string, 10)` you can push 10 member ,before you push 11th you should pop some member the number means max n in the chan at the same time.