No, the property blocks the link when this link is received. Pretty pointless, to be honest ... this is more common:
private readonly object mutex = new object(); private Foo foo = ...; public Foo Foo { get { lock(mutex) { return foo; } } }
This lock will only cover access to its own resource and will not provide any protection for operations performed using Foo . However, this is not the same as not having a lock at all, because as long as a variable is written only with the same lock, it ensures that any time you read the Foo property, you get access to the most recent value from the property ... without blocking, there is no memory barrier, and you can get an "outdated" result.
This is pretty weak, but worth knowing.
Personally, I try to make very few types thread safe, and they have more appropriate operations ... but if you want to write code that modified and read properties from multiple threads, this is one way to do this, Using volatile can help too, but the semantics of this The method is disgustingly subtle.
source share