Note that when each time the lock statement is executed it will evaluate the current reference pointed to by the parameter you pass to it. In this case as you are overwriting the variable that is passed to lock so each time it is executed it will lock on a different reference.
You should never lock on an object that is modified within the lock statement. Also, you should never lock on a value type (as there is no global reference) nor lock on this
(as you don't control which other classes can have a reference to yours and lock on it).
As a guideline you should look to lock on a dedicated object created for this purpose and in my opinion this object should also be defined as readonly
.
private readonly _shared = new object();
private void SomeMethod()
{
lock (_shared)
{
// Stuff
}
}