C# Threading Read Write locks : <p>Hi what will be the cleanest solution for the following pattern ?</p>

<p>Given a class for Read and Write some file/resouce, providing already implemented "read()" and "write()" functions. Create a "Read()" and "Write()" function that would wrap the "read()" and "write()"and prevent threads from interfering as follows:</p>

<p>a. multiple threads are allowed to Read</p>

<p>b. Only one thread is allowed to Write - so if a thread is already writing the other threads must wait.</p>

<p>c. writing must be prevented while a thread is reading and vice versa</p>
