DCSIMG
Multi-Threading is Hard – Who do you trust? - .NET Geek

.NET Geek

"It is upon the Trunk that a gentleman works" - Confucius

Multi-Threading is Hard – Who do you trust?

Something has been bothering me for quite some time and I am frankly not entirely sure what to do.

I have been working on a multi-threaded server application for over a year and feel that I have a decent grasp on multi-threading. More importantly, I have learned to respect the complexity.

So what is bothering me? Over the last few months I have encountered a number of blog posts that propose some solution with code that multi-threaded.

The problem – It’s Wrong!

Sometimes I send an email to the author, but for the most part, the posts are not being updated. That leaves the potential for other developers to take code from their trusted source and use it. Only to find down the road, maybe only after a year in production when the volume strains the system. You might claim that you cannot trust anyone, but multi-threading is complex enough that it is easy to be tempted to grab something from someone you otherwise believe knows his stuff. The problem I see most often is that of a lack of understanding of memory barriers and volatility. This is a basic concept if you do any kind of multi-threading and I am mostly surprised.

Besides sending an email to the author I am not going to start to blog about bad sources for multi-threading.

So where do you go?

Don’t trust code you find online. If you don’t understand it, don’t use it. (assuming it is not copyrighted and that you are allowed to grab it)

Do you know of any good sources for multi-threaded programming?

Comments

dhelper said:

Another good resource is the free E-Book "Threading in C#" - www.albahari.com/threading

# June 4, 2009 2:32 PM

Kim said:

@Dror, that is the same link that I linked to in the post. But thanks for the comment anyhow. :-)

# June 4, 2009 5:14 PM

splintor said:

Herb Sutter (from Microsoft) recently writes a lot about concurrency. Check herbsutter.wordpress.com and on his site http://www.gotw.ca/

# June 7, 2009 8:50 AM

Matt said:

I have found this article worth reading

www.yoda.arachsys.com/.../threads

Matt

# June 9, 2009 4:53 AM

Kim said:

@Matt, thanks.

# June 9, 2009 11:29 AM

Mitch Wheat said:

Joe Albahari's online resource that you linked to is excellent, as is Jon Skeet's article. And I agree with your comments about the amount of wrong threaded code out there!

# June 14, 2009 8:18 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: