'Should i use static lock object or instance object?
I am working with an asp.net webapi program (not .net core). there is a class that has read/write files function. in order to keep the thread-safe, I want to add a lock.
someone suggest below code:
private static readonly object Locker = new object();
And someone suggests I should use an instance locker. which is correct? what's the scope of the locker?
if the program creates multiple instances, will the locker still work?
Or should I make this class Singleton?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
