Created
March 1, 2017 21:31
-
-
Save jcsalem/28133cc6a1dd730bf4ac010de98a0e89 to your computer and use it in GitHub Desktop.
No race condition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main_test | |
import ( | |
"testing" | |
"time" | |
) | |
func TestRaceys(t *testing.T) { | |
var race bool | |
go func() { | |
for i := 0; i < 100000; i++ { | |
race = true | |
race = false | |
} | |
}() | |
go func() { | |
for i := 0; i < 100000; i++ { | |
if race { | |
} | |
} | |
}() | |
time.Sleep(time.Second * 2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment