3 ms·
Nice reminder that different kinds of race conditions exist, even without shared mutable data! One thing I wish the article mentioned: In the given example, an
by jkrems 6y ago
Nice reminder that different kinds of race conditions exist, even without shared mutable data!
One thing I wish the article mentioned: In the given example, another solution would have been to make the balance change safe. E.g. `addBalance()` or `updateBalanceIfEqual(old, new)`. Requiring a mutex around each call site that needs to be used correctly (and keeps being used correctly over time) seems like a pretty fragile way out.