The techie in me RSS 2.0
 Saturday, October 02, 2010

I am sure that most you have read this in the MSDN documentation, it appears almost everywhere. Recently while brainstorming about a deadlock issue in our project someone raised this topic. ‘Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe’, and claimed that all Framework type static instances are thread safe.

My opinion is this is bit misleading. This doesn't mean that all type in .NET framework are thread safe in static instance, nor that all static instance of any type is thread safe. If you think for a sec, nothing is thread safe by default, the author has to make a type thread safe, in this case MS has taken the time to verify that they are thread safe (which is very easy if they don't touch shared data). So it is your responsibility to make your class/type is thread safe.

I am sure MS is aware of this confusing statement. In old days it used to be only the two sentences in documentation (as above), but now you can see they are elaborating it bit more. Check here documentation for Array

And check this out, Thread Safety for TaskFactory says,

All public and protected members of TaskFactory are thread-safe and may be used concurrently from multiple threads

Hope that helps.

 

Rujith

Saturday, October 02, 2010 10:23:00 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Coding | Everything
Comments are closed.
About me
Name : Rujith Anand Send mail to the author(s)
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
Blogs I read
Disclaimer

Disclaimer
Postings are provided as is with no warranties, and confer no rights. Opinions expressed here are my own delusions; my employers at best shake their heads and sigh, at worst repudiate the content with extreme prejudice, whenever it manages to appear on their radar.

© Copyright 2012
Rujith Anand

Statistics
Advertisement
All Content © 2012, Rujith Anand