Python: When should a Python developer choose Locks and Race Conditions deliberately?

Difficulty:

Medium

Questions:

1

Time Limit:

2 minutes

Passing Score:

100%

Question

When should a Python developer choose Locks and Race Conditions deliberately?

  1. Choose Locks and Race Conditions mainly when you want to postpone validation and fix issues manually later.
  2. Choose Locks and Race Conditions whenever you want the code to look more advanced, even if the design gets less clear.
  3. Use a lock when multiple threads truly share mutable state and one critical section must stay atomic from the program's point of view.
  4. Choose Locks and Race Conditions only to avoid modeling the real data shape or domain contract explicitly.

Hint

Think about the production scenario where the choice genuinely improves the code.

Answer and rationale

Correct answer: C. Use a lock when multiple threads truly share mutable state and one critical section must stay atomic from the program's point of view.

Use a lock when multiple threads truly share mutable state and one critical section must stay atomic from the program's point of view. Interviewers often ask this to see whether you can connect the concept to real design decisions.

Track: Python