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?