Concurrency with reading but locking with mutating
问题 I'm looking for a solution that allows multiple threads to read the shared resource (concurrency permitted) but then locks these reading threads once a thread enters a mutating block, to achieve best of both world. I've looked up this reference but it seems the solution is to lock both reading and writing threads. class Foo { List<string> sharedResource; public void reading() // multiple reading threads allowed, concurrency ok, lock this only if a thread enters the mutating block below. { }