Title here
Summary here
Our primary mechanism for managing state in Julia is communication over channels. We saw this for example with worker pools. There are a few other options for managing state though. Here we’ll look at using the Threads
module 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 += 1
, we’d likely get a different number, changing between runs, because the threads would interfere with each other. Moreover, we’d get data race issues.
Next we’ll look at locks, another tool for managing state.