diff --git a/examples/atomic-counters/atomic-counters.go b/examples/atomic-counters/atomic-counters.go index 046a347..e96752d 100644 --- a/examples/atomic-counters/atomic-counters.go +++ b/examples/atomic-counters/atomic-counters.go @@ -34,6 +34,10 @@ func main() { // use `AddUint64`, giving it the memory // address of our `ops` counter with the // `&` syntax. + + // Also try by replacing `atomic.AddUint64(&ops, 1)` + // with `ops++` and see the difference in output each + // time we run the example atomic.AddUint64(&ops, 1) } wg.Done() diff --git a/examples/atomic-counters/atomic-counters.hash b/examples/atomic-counters/atomic-counters.hash index f4c10e6..d4c19e7 100644 --- a/examples/atomic-counters/atomic-counters.hash +++ b/examples/atomic-counters/atomic-counters.hash @@ -1,2 +1,2 @@ -7b491b40d56a77b01d8e2bd08366de081a4e8d99 -j-14agntvEO +411d812735b41f901f82f31f55e74895dc837574 +pWwgacr1iKb diff --git a/public/atomic-counters b/public/atomic-counters index 6548101..84ab63a 100644 --- a/public/atomic-counters +++ b/public/atomic-counters @@ -46,7 +46,7 @@ counters accessed by multiple goroutines.
package main
ops
counter with the
Also try by replacing atomic.AddUint64(&ops, 1)
+with ops++
and see the difference in output each
+time we run the example
atomic.AddUint64(&ops, 1) ++ atomic.AddUint64(&ops, 1) } wg.Done() }()