Skip to content
Sharp

Java Threading · interview question

Where should a slow payment API call usually happen when protecting inventory with a lock?

Multiple choiceMediumchapter-15-curatedpremiumjava-threadingsynchronized-locks
Choose one answer
Answer and explanation

Correct answer

C. Outside the critical section, after the shared inventory mutation is protected

Why

Locks should guard the narrow in-memory critical section only. Holding them during slow network calls serializes unrelated work and destroys throughput.

Test yourself on Java Threading

A free test with instant, explained results. No account needed.

Start free test
All Java Threading questions →