Merge remote-tracking branch 'buger/patch-1'
This commit is contained in:
commit
2c8af9ae1c
@ -10,6 +10,7 @@ package main
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
import "time"
|
import "time"
|
||||||
import "sync/atomic"
|
import "sync/atomic"
|
||||||
|
import "runtime"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
@ -23,13 +24,13 @@ func main() {
|
|||||||
for i := 0; i < 50; i++ {
|
for i := 0; i < 50; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
time.Sleep(time.Millisecond)
|
|
||||||
|
|
||||||
// To atomically increment the counter we
|
// To atomically increment the counter we
|
||||||
// use `AddUint64`, giving it the memory
|
// use `AddUint64`, giving it the memory
|
||||||
// address of our `ops` counter with the
|
// address of our `ops` counter with the
|
||||||
// `&` syntax.
|
// `&` syntax.
|
||||||
atomic.AddUint64(&ops, 1)
|
atomic.AddUint64(&ops, 1)
|
||||||
|
|
||||||
|
runtime.Gosched()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user