Synchronization in case of Inheritance in java
inheritance, java, multithreading
Solution
There is no parent object lock or child object lock. There is only one lock, the object's. In this case, it will be `p`'s.
Threads will block when entering a parent's synchronized method if another thread has the lock in a child's synchronized method, and vice versa.
Problem
Suppose there are 2 classes, Parent class and Child class which extends Parent class. Now and both have two method which are synchronized.My question which object lock will be use for locking this synchronized methods i create object like : Parent p=new Child(); Is is parent object lock or Child object lock?