Skip to content
Sharp

Concurrency basics · interview question

Why does using synchronized on a method with respect to its class instance change runtime behavior?

Multiple choiceMediumchapter-15-curatedpremiumconcurrencysynchronized-and-locks
Choose one answer
Answer and explanation

Correct answer

B. It locks the instance on which the method is called.

Why

Using synchronized on a method locks the instance (the 'this' object) on which the method is called, preventing other threads from executing any other synchronized method on the same instance.

Test yourself on Concurrency basics

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

Start free test
All Concurrency basics questions →