Hi m(are you the one from James Bond
I give you two explanations:
1 - only one lock per object.
2 - "synchronized" tells a thread, "You can only enter, if you have the lock on the object!"
Can another thread get the lock, when trying to access another synchronzed method?
Imagine a house with 5 rooms, 3 of them have a door which can be locked with a key and are per default locked. The housekeeper, Mr Scheduler, has only one key and he is the only one to give it to someone.
Now we have three guys in the house and all really need to go for a pee
The bathroom is one of these three locked rooms. So Mr Scheduler decides to give the key to the guy, who currently has the highest priority. That is Peter, because he has been drinking water the whole day and really needs to ...
Peter gets the key, enters the bathroom and locks the door.
The second guy is hungry and wants to enter the kitchen, that is also locked. But the key is with Peter in the bathroom!
How can he enter the kitchen?