Verified interview challenge
Repair a bank-account race condition
Make concurrent deposits safe without modifying or copying the existing account implementation.
Unlock with Full AccessThe challenge
An existing deposit method reads a balance, waits and writes the updated value. Concurrent calls can interfere even though each deposit looks correct in isolation.
Build a compatible thread-safe account while reusing the original method. You cannot fix the problem by rewriting its body, so the exercise tests how to add coordination around behaviour you do not control.
What you'll practise
Lost-update diagnosis
Explain which interleavings allow concurrent deposits to overwrite one another.
Safe composition
Add synchronisation around existing behaviour while preserving the public interface.
# Your implementation goes here
# Run examples and inspect results
# Full starter code includedRun your code to see results.