Thank you Sir now i understand the difference
2018. május 4., péntek 15:21:49 UTC+2 időpontban k1at...@gmail.com a következőt írta: > > Hi > > i dont' understn what is the difference between : > > ch := make(chan bool,1) vs. ch := make(chan bool) > > this sample works well : > > package main > > import ( > "fmt" > "sync" > ) > > var x = 0 > > func increment(wg *sync.WaitGroup, ch chan bool) { > ch <- true > x = x + 1 > <-ch > wg.Done() > } > func main() { > var w sync.WaitGroup > ch := make(chan bool,1) <------it is OK , but if i > change to ch := make(chan bool) - it doesn't work > for i := 0; i < 1000; i++ { > w.Add(1) > go increment(&w, ch) > } > w.Wait() > fmt.Println("final value of x", x) > } > > Thank you in advance > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.