Explaining Race Conditions to Non Programmers

Explaining Race Conditions to Non Programmers

A few weeks ago, I was down in Columbus at a coffee shop. This place happened to have a bathroom which needed a key to use. I went to the counter to ask for the key because mother nature called, but the key was nowhere to be found. Somebody was already in the bathroom and had the key with them.

No problem, I stood outside the bathroom door and soon enough, a gentleman appeared. In a knowing manner, he offered me the key. In a moment of self admiration for my wit, I declined the key. I grabbed the door before it shut. We both smiled, knowing that I was fine getting in the bathroom without the key.

I felt proud of my efficiency. I didn’t need to hold up use of the key. As a sat down, as Gandolf would say, “things were put into motion which could not be undone.” But, it was only then that I realized this bathroom didn’t have stalls. I was exposed.

This was a race condition waiting to happen….

At any minute, somebody could walk in and I was trapped. The key was now happily laying on the counter with the Baristas. Any unknowing customer could grab the key and head toward the bathroom.

This had all the making of a classic race condition in programming – self admiring wit, gloating thoughts of efficiency, and a lack of foresight.

So, the next time you use a public bathroom which needs a key, remember to take the key. For those of you that do program, remember to do proper file locking, or lock management in a distributed system.

Remember the bathroom rule!!!

One comment on “Explaining Race Conditions to Non Programmers”

Leave a Reply

Your email address will not be published. Required fields are marked *