Quantcast
Channel: Thread Lock Question
Viewing all articles
Browse latest Browse all 6

Thread Lock Question

$
0
0

I'm just kind of curious on this.  I wasn't sure how to test it on my own as it is a threading issue and not reliable.  Consider the following example.

 

Code Snippet

private object LOCK = new object();

 

private bool _Foo;

private bool Foo

{

get

{lock(LOCK){return _Foo}}

set

{lock(LOCK){_Foo = value;}}

}

 

Will this code ensure that is long as I use Foo instead of _Foo I shouldn't have to worry about any  concurrency issues with _Foo?

 

Thanks

~Justin

 


Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>