ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim(); ListIn the above code, a shared resource (a List of integers) is protected by a ReaderWriterLockSlim. The WriteResource method takes a value and adds it to the shared resource. Its critical section is protected by an exclusive write lock obtained by calling EnterWriteLock. The ReadResource method reads an element from the shared resource using a shared read lock obtained by calling EnterReadLock. This class is a part of the .NET Framework Class Library.sharedResource = new List (); // Write thread void WriteResource(int value) { rwLock.EnterWriteLock(); try { sharedResource.Add(value); } finally { rwLock.ExitWriteLock(); } } // Read thread int ReadResource(int index) { rwLock.EnterReadLock(); try { return sharedResource[index]; } finally { rwLock.ExitReadLock(); } }