// access to shared memory among threads // controlled using atomics. // For this program (and many like it) atomics are far // preferable to locks (faster and less error prone) // // The basic idea here is to start a bunch of thread and // have them all increment a single variable // // This version differs from the standard in the timing of the // the update of the shared memory. In his case only // update at the end of the run. // // Author: gtowell // Created: August 2022 package main import ( "fmt" "sync" "sync/atomic" ) var ( counter int64 ) func main() { var wg sync.WaitGroup var threads int64 = 100 var times int64 = 100000000 var rz int64 for rz=0; rz