Question about the Lock statement

Hey guys.

So I’ve been messing around with the Lock statement when a question popped into my mind. I find it kinda hard to explain, but here we go:

If an object is locked somewhere, can the object then still be used simultaneously somewhere else in the code, if you use it unlocked? Like this:

// This runs at the same time ..

Lock(obj)

{

Console.WriteLine(obj.property);

}

// .. As this.

Console.WriteLine(obj.property);

Would the unlocked statement be able to use the object, even if it is locked somewhere else, because you use it unlocked?

EDIT: Thanks for the answers guys! I ended up making a small code experiment to see it with my own eyes: http://i.imgur.com/X7v6SBg.png

submitted by /u/PinkySmartass
[link] [comments]

Leave a Reply