Bird
0
0

In the following code snippet, what is the main concurrency issue?

medium📝 Analysis Q14 of 15
LLD - Design — Parking Lot System
In the following code snippet, what is the main concurrency issue?
lock.acquire()
shared_data.append(1)
# Missing lock.release()
ADeadlock due to missing lock release
BData race on shared_data
CSyntax error in lock usage
DNo issue, code is safe
Step-by-Step Solution
Solution:
  1. Step 1: Identify missing lock release

    The code acquires a lock but never releases it, so other threads waiting for the lock will block forever.
  2. Step 2: Understand deadlock impact

    This causes a deadlock where threads cannot proceed, halting system progress.
  3. Final Answer:

    Deadlock due to missing lock release -> Option A
  4. Quick Check:

    Missing release causes deadlock = A [OK]
Quick Trick: Always release locks after acquiring [OK]
Common Mistakes:
MISTAKES
  • Thinking it's a syntax error
  • Assuming no issue without release
  • Confusing deadlock with data race

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes