Explain what is a Race Condition to 5 years old

Technology CommunityCategory: ConcurrencyExplain what is a Race Condition to 5 years old
VietMX Staff asked 3 years ago
  • You are planning to go to a movie at 5 pm. You inquire about the availability of the tickets at 4 pm. The representative says that they are available.
  • You relax and reach the ticket window 5 minutes before the show. I’m sure you can guess what happens: it’s a full house.

The problem here was inĀ the duration between the check and the action. You inquired at 4 and acted at 5. In the meantime, someone else grabbed the tickets. That’s a race condition – specifically a “check-then-act” scenario of race conditions.