Index Ai Academy
Glossary · Phase 7 · Software engineering

Race condition

Also written: race conditions

A bug where the result depends on the timing of tasks running at once, such as two updates where one gets lost.

Two people share a tally on a whiteboard. Both read 10, both add one in their heads, and both write 11. Two people counted, and the board went up by one. When two threads share data, their steps can interleave in any order in the same way. Take count += 1. It looks like one step, but it's three: read count, add 1, write it back. If two threads both read before either writes, one update is lost. That's a race condition: the result depends on timing.

Try it now

Watch the ready list. Each task runs to its next yield, then goes to the back of the line. The log shows them interleaving.

Learn it properly

Concurrency and async · Do many things at once: processes, threads and the event loop. About 40 minutes.

Create a free account See what's in the lesson

Other terms from the same lesson

Never trained an AI?

Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.

Teach it to write