The main reason you want to block the reading of a byte array is to avoid "reading phantom" or other non-repeatable reading - if the author partially refreshes the array, the reader may see some old values โโand some new values, or the old value, and then the new value if it reads it again.
For example, if you have an array containing [1, 2, 3, 4, 5, 6] and a writer thread that accepts SyncLock and loops over the array, adding 1 to each element, a reader that SyncLock cannot see weirdness like [ 2, 3, 4, 4, 5, 6] - only threads that actually accept SyncLock will receive any security.
source share