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 moment of self admiration for my wit, I declined the key. I grabbed the door before it shut. We both smiled, both 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 – “things were put into motion which could not be undone” as Gandolf would say. 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 counter with the Baristas. Any unknowing customer could grab 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!!!

1 Comment

  1. I practically fell out laughing reading this! Thanks!

Leave a Reply

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