None
SQ
Go Language concurrency and an easy pitfall
['Ashish Bhatia']
ashishb.net
Go 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 package main import ( "fmt" "sync" ) func main () { arr := [] int { 1 , 2 , 3 } var wg sync.WaitGroup for i := 0 ; i < len (arr); i ++ { wg. Go 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 package main import ( "fmt" "sync" ) func main () { arr := [] int { 1 , 2 , 3 } var wg sync.WaitGroup for i := 0 ; i < len (arr); i ++ { wg. Done () }(i) // Capture the value at the time of thread creation } // Wait till all the threads finish wg.