Click here to Skip to main content
15,885,216 members
Articles / Programming Languages / C#

The Simplest Implementation of a Reader-Writer Lock for .NET

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
24 Jan 2022CPOL1 min read 10.8K   158   12  
An implementation of a basic Reader-Writer lock using only the System.Threading.Monitor class
The article shows how you can create a simple synchronization primitive that restricts access to a shared resource to a single writer, while still allowing multiple readers to access it simultaneously. Of course, it's not supposed to replace the highly optimized default ReaderWriterLockSlim implementation, but nonetheless, it's a very interesting demonstration of how Monitor.Wait and Monitor.PulseAll can be used to achieve the goal.

Views

Daily Counts

Downloads

Weekly Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Belarus Belarus
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions