c# - ReaderWriterLock vs lock{} -


Please tell what the main differences are and when should I use.
Focus on web multi-threaded applications

Only one to execute the code at the same time Allows threads. It can be more efficient if you are using .NET 3.5, it can be faster to allow multiple threads to read or write at the same time. So if your sharing resource is being written more often, then use ReaderWriterLockSlim . A good example for using it is a file that you read many times (on each request) and you rarely update the content of the file. So when you read from the file, you enter the reading lock, so many requests can open it to read and when you decide to write, then you enter a lock lock, a lock on the file < The basic meaning of using code> is that you can serve a request at a time.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -