Skip to content
Sharp

Java Threading · interview question

Why is the 'check-then-act' pattern problematic in a concurrent environment?

Multiple choiceMediumchapter-15-curatedpremiumjava-threadingrace-conditions
Choose one answer
Answer and explanation

Correct answer

D. The check and act operations can be interleaved by other threads.

Why

In a concurrent environment, the 'check-then-act' pattern can fail because after a check is performed, another thread can change the state before the act, leading to unexpected behavior.

Test yourself on Java Threading

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

Start free test
All Java Threading questions →