In my opinion, calling lock/unlock methods is an unnecessary complication, which actually defeats the purpose of the synchronized keyword.
Here's how my system reserves seats:
Client calls reserveSeats method on database server. This method takes an int for the number of seats requested, and another int -- the record number. It checks if the seats are available, and if so subtracts appropriately.
The reserveSeats method is synchronized. Thus, all other clients will have to wait for the first one to finish before it can get into the reserveSeats method.
I just don't get all this unnecessary complication with locks, lock/unlock methods, LockManagers, ClientIDs... Using these things only defeats the purpose and elegance of synchronized methods. I don't understand why Sun would want us to misuse their language like this.
If I am wrong, please someone correct me.
Moreover, if I neglect to implement lock/unlock methods will I fail (even if the system works fine)?
Any insight is appreciated!
Thanks!