I have a black Labrador named Sofie. She's about 2 and a half now, but still a puppy at heart. Here's a picture of her (along with her best friend, Sierra, who is a yellow lab): One morning, Sofie reminded me of a valuable issue with threading and race conditions. Our morning ritual for feeding is that Sofie starts dancing out of anticipation for breakfast (literally - fellow dog owners know what I mean), which usually involves her jumping up and down and chasing her tail in circles. I then tell her to "sit" and then "stay", which means she's supposed to be stationary and not move until I say "OK". I then proceed to get her food, fill her dish, and wait a minute to reinforce her discipline. I then say "ok" and she rushes to her food dish and enjoys the life of a dog.
So what's the lesson?One morning we came down, and instead of dancing, she just sat down and waited. So I proceeded to fill her dish ... and then she immediately ran and ate the food. I realized that because she was already sitting, I never issued the "sit" and "stay" commands. To be more technical: Sofie and I each represent a thread, and her being in a "sitting" state lulled me into a false sense of security where I got lazy and avoided uses the synchronization primitives. Thus she was not ordered to wait and free to eat her food at her convenience.