Controlling concurrent access to a shared, mutable resource is a classic problem. Clients request, and later release, either read-only or read-write access to the resource. To preserve consistency but minimize waiting, one usually wishes to allow either any number of readers or a single writer, but not both, to have access at any one time.
While a thread is updating, no other thread can read the data. The name is misleading. It may cause you to think there are two locks; in reality there is a single lock that restricts both reading and writing.
|
|