8000 you're doing great · Abhicodeitout/GolangTraining@e67e348 · GitHub
[go: up one dir, main page]

Skip to content

Commit e67e348

Browse files
committed
you're doing great
1 parent 17a2b6b commit e67e348

File tree

2 files changed

+5
-5
lines changed
  • 22_go-routines
    • 08_atomicity
    • 12_channels_pipeline/04_challenge-solution/02_another-solution

2 files changed

+5
-5
lines changed

22_go-routines/08_atomicity/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

22_go-routines/12_channels_pipeline/04_challenge-solution/02_another-solution/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ const rdLimit = 20
1212
func 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)

0 commit comments

Comments
 (0)
0