Semicolony ELI5 · comic

Race conditions.

Two people grabbing the last cookie at once because each looked, saw it there, and reached.

  1. Mine!
    the last seat
    1

    Two people both reach for the one last seat at the very same moment.

  2. 100 both read 100
    2

    In code: two threads both read the same value, a balance of 100.

  3. 70 70 70 one withdrawal vanished
    3

    Each subtracts 30 and writes 70 back — so one withdrawal silently disappears.

  4. After you.
    waits its turn
    4

    A lock fixes it: only one thread enters at a time, the other waits its turn.

  5. You go first… no, you.
    each waits for the other
    5

    But locks have their own trap — deadlock, where each thread waits for the other forever.

  6. each its own copy
    6

    The cleanest fix is to not share at all: give each thread its own copy.

Two threads grab the same data at once — and a lock, or sharing nothing, is the fix.
Semicolony semicolony.dev/eli5/race-conditions/comic
← All ELI5 explainers