Practice mode Java

What lock does a synchronized instance method acquire in Java?

Correct answer A. The intrinsic lock of the object it is called on

Explanation

A synchronized instance method locks the monitor of this, so two synchronized instance methods on the same object exclude each other while calls on different objects do not. A static synchronized method instead locks the Class object. Each object has only one intrinsic lock, and it is reentrant for the thread that already holds it.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.