#8 most askedVery commonMediumConcurrency
What is a race condition?
New to Concurrency? Learn it from scratch firstRace Conditions & How to Avoid Them โ
๐ข Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.What is a race condition? Predict what this simulation shows, then explain how to fix it.
๐ฎ Predict the output
balance = 100
# Two "threads" both withdraw 30, interleaved: each reads before the other writes
a_read = balance
b_read = balance
balance = a_read - 30
balance = b_read - 30
print(balance)
๐ค Answer it out loud, then check yourself
Say your answer as if the interviewer is listening (30โ90 seconds). Then reveal what a strong answer covers and tick what you said.
Answer out loud first, then compare.
Want to rehearse it?Answer this to the AI interviewer and get a verdict โ