Someone to explain this task?
Solved it but I don't really know what I've done
You must be signed in to leave a comment
2 March 2021, 15:19
There is a problem in that code in that it has this sequence: 1) RealEstate.revalidate() calls Apartment.revalidate() 2) Apartment.revalidate() calls RealEstate.up() So the stack call would look like this: RealEstate.revalidate() << this locks all synchronized methods in RealEstate until it completes Apartment.revalidate() RealEstate.up() << can't access because the method is locked until the first step finishes The third step will literally wait until the synchronized block allows it to continue, however the first step (which has the initial lock) can't finish, and release its lock, until the third step finishes. This will deadlock the program and is the problem that needs to be fixed. Here is some reading deadlock Java concurrency If you don't feel like reading this all, skip to part "10.1.4 Open Calls"
2 March 2021, 16:26
Crystal clear! Thanks again Guadalupe