I was recently in an interview and the tech guy asked me about how to make an application thread-safe.
Well, after explaining the lock()
correctly, he s
If you have only one instance of a class that shares between multiple threads, it's ok to use normal object. but if you have multiple objects of a class that share between multiple threads, you have to use static object.
On the other hand, with normal object you can manage concurrency for one instance of a class and with static object you can manage concurrency in the scope of all instances of a class.