3 ms·
> This solution is vulnerable to a data race if another user concurrently updates the value. And this, of course, they are expected to understand in an unfamil
by jseban 5y ago
> This solution is vulnerable to a data race if another user concurrently updates the value.
And this, of course, they are expected to understand in an unfamiliar code base with 3 hours total for the whole task. LOL
- FartyMcFarter 5y agoYou don't need to see the rest of the codebase to realise that's probably wrong. In any codebase, locks only apply to the scope they're in.
- jseban 5y agoThe key word here being "probably".
- FartyMcFarter 5y agoYes - so the safe thing to do is to put the lock outside the loop. Anyone experienced in multithreading will instinctively know this is the correct alternative for any codebase (and it performs better too).
- maccard 5y agoNo, not knowing that is a fundamental misunderstandings of either locks or scope. Depending on the role and job level that may be table stakes.