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) {
23
23
for i := 0 ; i < 20 ; i ++ {
24
24
time .Sleep (time .Duration (rand .Intn (3 )) * time .Millisecond )
25
25
atomic .AddInt64 (& counter , 1 )
26
- fmt .Println (s , i , "Counter:" , counter )
26
+ fmt .Println (s , i , "Counter:" , atomic . LoadInt64 ( & counter ) )
27
27
}
28
28
wg .Done ()
29
29
}
Original file line number Diff line number Diff line change @@ -12,18 +12,18 @@ const rdLimit = 20
12
12
func main () {
13
13
var w sync.WaitGroup
14
14
w .Add (numFactorials )
15
- factorial (numFactorials , & w )
15
+ factorial (& w )
16
16
w .Wait ()
17
17
18
18
}
19
19
20
- func factorial (n int , wmain * sync.WaitGroup ) {
20
+ func factorial (wmain * sync.WaitGroup ) {
21
21
var w sync.WaitGroup
22
22
rand .Seed (42 )
23
23
24
- w .Add (n + 1 )
24
+ w .Add (numFactorials + 1 )
25
25
26
- for j := 1 ; j <= n ; j ++ {
26
+ for j := 1 ; j <= numFactorials ; j ++ {
27
27
28
28
go func () {
29
29
f := rand .Intn (rdLimit )
You can’t perform that action at this time.
0 commit comments