Merge remote-tracking branch 'buger/patch-1'

This commit is contained in:
Mark McGranaghan 2013-06-20 08:10:24 -07:00
commit 2c8af9ae1c

View File

@ -10,6 +10,7 @@ package main
import "fmt"
import "time"
import "sync/atomic"
import "runtime"
func main() {
@ -22,14 +23,14 @@ func main() {
// once a millisecond.
for i := 0; i < 50; i++ {
go func() {
for {
time.Sleep(time.Millisecond)
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)
runtime.Gosched()
}
}()
}