C# Locking an object that is reassigned in lock block

Posted by Theo Zographos on Stack Overflow See other posts from Stack Overflow or by Theo Zographos
Published on 2010-06-02T11:54:37Z Indexed on 2010/06/02 12:03 UTC
Read the original article Hit count: 157

Filed under:
|
|

Hello,

I have this code in a class:

private static MyObject _locker = new MyObject();

...

lock (_locker)
{
     ...
     _locker = new MyObject();
     ...
}

Will it keep the lock on _locker ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about multithreading