...continued

This lesson continues the discussion of Mutex in Ruby.

We'll cover the following...

A mistaken belief is that we only need to synchronize access to shared resources when writing to them and not when reading them. Consider the snippet below. We have an array of size two initialized with true values. The writer thread flips the boolean values in all the array elements in a loop. Since the array is shared, we guard the write to the array in a mutex synchronize block. We have another reader thread that outputs the array to the console. With proper ...