In one process I’d like to do
S[1,1] += 1; sleep(1); on a loop.
In the other process I’d like to do
print(S[1,1]); sleep(0.5); on a loop.
Is this safe when
S is a SharedArray? What if the attempted read by the second process happens “at the same time” as the attempted write by the first process? Do I need to use a lock or synchronization primitive to ensure that the processes will take turns in accessing S?