Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

synchronized method in derived class

If base class A has a "public synchronized void method(){}" which was not overridden by its derived class B,then what will the lock be (i.e. will it be the derived class object or the base class object) that is used to access the synchronized method in class B?

like image 863
Sameer Sarmah Avatar asked Apr 10 '26 13:04

Sameer Sarmah


1 Answers

There is no "base class object".

synchronized methods lock on the instance they're called on.

like image 177
SLaks Avatar answered Apr 15 '26 04:04

SLaks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!