A couple of times I have came across this code where a local variable in a class ( its NOT a static variable) has been used in a lock.
public class SomeClass
{
private object obj = new object();
....
....
lock(obj)
{
}
}
Is there any point of locking given that its an instance variables?
Multiple threads could be acting on the same instance and a lock is needed for thread-safety. Think, for example, of a shared queue.