Here’s the translated code and explanation in Markdown format suitable for Hugo:
The primary mechanism for managing state in many languages is communication over channels or message passing. However, there are a few other options for managing state. Here we’ll look at using atomic operations for atomic counters accessed by multiple threads.
We expect to get exactly 50,000 operations. Had we used a non-atomic integer and incremented it with ops++, we’d likely get a different number, changing between runs, because the threads would interfere with each other. Moreover, we’d get data race failures when running with proper concurrency analysis tools.
Next we’ll look at locks, another tool for managing state.