Lost Updates Between Threads

Talk it through with a coach who asks guiding questions and gives hints until you reach the answer. Pass to mark the challenge as completed.

The problem

  • medium
  • Pro

In a code review you spot four threads that each add one to a shared counter with counter plus-equals one, and no lock. The author says the global interpreter lock makes this safe. Explain why it isn't, and how to fix it.

Talk this problem through with an AI coach

This is a Pro challenge. Sign in with Google, then upgrade to start a voice session.

Start free →