Page 1 of 1

About Question enthuware.ocpjp.v11.2.1754 :

Posted: Tue Jan 16, 2024 11:53 am
by hsnclk
Option B: When a synchronized method ends with a checked exception, the intrinsic lock held by the thread is released automatically.
Option C: A thread will retain the intrinsic lock if the return from a synchronized method is caused due to an uncaught unchecked exception. (Explanation of this: The intrinsic lock is released when the method ends. Irrespective of how it ends.)

I understood option B but I didn't fully understand option C. Is the only difference between them their exception type? If I understood correctly, synchronized method throws checked exception, the intrinsic lock is released but synchronized method throws unchecked exception, the intrinsic lock is NOT released.

Re: About Question enthuware.ocpjp.v11.2.1754 :

Posted: Wed Jan 17, 2024 6:45 am
by admin
Option 3 is wrong because it says "A thread will *retain* the intrinsic lock if ..." but as the explanation says, "The intrinsic lock is released when the method ends. Irrespective of how it ends."

There is no contradiction between option 2 and 3.