The documentation for ReadOnlyCollection(of T) states that:

A ReadOnlyCollection(Of T) can support multiple readers concurrently, as long as the collection is not modified. Even so, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.

My question regards the bolded part:

  1. why is enumerating through a collection intrinsically not thread-safe
  2. what are the possible implications, and
  3. what are commonly-used workarounds?
Edit
Report