Skip to content
Sharp

System Design · interview question

During a code review, you spot a potential race condition. What is one effective way to address this in Java?

Multiple choiceHardchapter-20-curatedpremiumsystem-designdefending-tradeoffs
Choose one answer
Answer and explanation

Correct answer

B. Using synchronized blocks

Why

Using synchronized blocks in Java can help manage access to shared resources, preventing race conditions by ensuring that only one thread can access the critical section of code at a time.

Test yourself on System Design

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

Start free test
All System Design questions →