Re:The best engineering interview question I've ever gotten
by maccard on Monday April 18, 2022 @05:11AM
(#31068719)
No, not knowing that is a fundamental misunderstandings of either locks or scope. Depending on the role and job level that may be table stakes.
Re:The best engineering interview question I've ever gotten
by FartyMcFarter on Monday April 18, 2022 @04:32AM
(#31068537)
You 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.
Re:The best engineering interview question I've ever gotten
by jseban on Monday April 18, 2022 @05:02AM
(#31068672)
The key word here being "probably".
Re:The best engineering interview question I've ever gotten
by FartyMcFarter on Monday April 18, 2022 @05:07AM
(#31068697)
Yes - 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).
And this, of course, they are expected to understand in an unfamiliar code base with 3 hours total for the whole task. LOL