Vinu Menon wrote:I have few doubts in Synchronization.
1)When we enter a synchronized non-static method we acquire a lock for an object.Does that mean the entire object is locked like both synchronized and non-synchronized methods?and what does object lock exactly mean?
When you call a synchronized non-static method, the current
thread acquires a lock on the object with which the method was called. This means that now no other thread will be able to execute synchronized non-static methods on that object. Other threads can however execute non-synchronized methods on the object. So the lock basically means that on that object no other thread can now execute synchronized non-static methods unless the current thread releases the lock either by calling wait or end of execution of the synchronized non-static method...