File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
12_channels_pipeline/04_challenge-solution/02_another-solution Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ func incrementor(s string) {
2323 for i := 0 ; i < 20 ; i ++ {
2424 time .Sleep (time .Duration (rand .Intn (3 )) * time .Millisecond )
2525 atomic .AddInt64 (& counter , 1 )
26- fmt .Println (s , i , "Counter:" , counter )
26+ fmt .Println (s , i , "Counter:" , atomic . LoadInt64 ( & counter ) )
2727 }
2828 wg .Done ()
2929}
Original file line number Diff line number Diff line change @@ -12,18 +12,18 @@ const rdLimit = 20
1212func main () {
1313 var w sync.WaitGroup
1414 w .Add (numFactorials )
15- factorial (numFactorials , & w )
15+ factorial (& w )
1616 w .Wait ()
1717
1818}
1919
20- func factorial (n int , wmain * sync.WaitGroup ) {
20+ func factorial (wmain * sync.WaitGroup ) {
2121 var w sync.WaitGroup
2222 rand .Seed (42 )
2323
24- w .Add (n + 1 )
24+ w .Add (numFactorials + 1 )
2525
26- for j := 1 ; j <= n ; j ++ {
26+ for j := 1 ; j <= numFactorials ; j ++ {
2727
2828 go func () {
2929 f := rand .Intn (rdLimit )
You can’t perform that action at this time.
0 commit comments