8000 Seed the "rand". · Abhicodeitout/GolangTraining@4e20697 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e20697

Browse files
authored
Seed the "rand".
The script is intended to show students what a Race Condition is, so it will trigger a race condition, that wasn't expected to be fixed. Just the "rand" seeded.
1 parent 67f6eb2 commit 4e20697

File tree

1 file changed

+1
-0
lines changed
  • 22_go-routines/06_race-condition

1 file changed

+1
-0
lines changed

22_go-routines/06_race-condition/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func main() {
1919
}
2020

2121
func incrementor(s string) {
22+
rand.Seed(time.Now().UnixNano())
2223
for i := 0; i < 20; i++ {
2324
x := counter
2425
x++

0 commit comments

Comments
 (0)
0