I understand the main function of the lock keyword from MSDN
Blocking statement (C # link)
The lock keyword denotes the lock statement as critical to receive a mutual exclusion lock for a given object that is executing and then release the lock.
When should you use a lock?
For example, this makes sense in multi-threaded applications because it protects data. But is it necessary when the application does not allocate other threads?
Are there any performance issues when using lock?
I just inherited an application that uses locks everywhere and it is single threaded and I want to know if I should leave them, are they even necessary?
Please note that this is rather a general question about knowledge, application speed is good, I want to know if this is a good design pattern that should be followed in the future, or should be avoided if absolutely necessary.
multithreading c # design-patterns locking
David Basarab Sep 12 '08 at 17:38 2008-09-12 17:38
source share