This commit is contained in:
Mark McGranaghan
2013-06-20 08:11:53 -07:00
parent 05b6731f1f
commit bc0c8b5918
2 changed files with 15 additions and 3 deletions

View File

@@ -23,14 +23,14 @@ func main() {
// once a millisecond.
for i := 0; i < 50; i++ {
go func() {
for {
for {
// To atomically increment the counter we
// use `AddUint64`, giving it the memory
// address of our `ops` counter with the
// `&` syntax.
atomic.AddUint64(&ops, 1)
// Allow other goroutines to proceed.
// Allow other goroutines to proceed.
runtime.Gosched()
}
}()