This post originated from an RSS feed registered with .NET Buzz
by Udi Dahan.
Original Post: Forgotten assumption for multithreading
Feed Title: Udi Dahan - The Software Simplist
Feed URL: http://feeds.feedburner.com/UdiDahan-TheSoftwareSimplist
Feed Description: I am a software simplist. I make this beast of architecting, analysing, designing, developing, testing, managing, deploying software systems simple.
This blog is about how I do it.
James Arendt found a race-condition in my ThreadSafeQueue. This is what I call a "coding bug".
First of all, I'm glad that James found and raised this issue because now I understand that I missed a critical design point when introducing the ThreadSafeQueue. There should only be one thread dequeuing. This, by design, eliminates the race condition described.
However, there's no reason not to move to the better implementation suggested - it still passes all the tests of the original implementation. I haven't yet been able to write a test that exposes the bug, but I'm not sure it's even possible to do so without substantially changing the implementation.
Thanks again to James.