I've read quite a bit of posts about locking, but none of them seem to address the same issue I'm thinking right now. Which is why I think I'm missing something related to this whole locking thing.
According to the instructions, if a thread (client) tries to lock an already locked record, it should wait (use of wait() method) until that record is unlocked (possibly forever until notifyAll(), no timeout) so it can proceed. But doesn't this mean the last thread will always overwrite the first one's update? When the better solution, would be to display a message to the last thread so it could try again?
Let's picture two users, John and Bill. They both want to book record number 6, and they highlight and hit the "book" button at almost the same time. If Bill was a bit faster, he would book the record successfully with his ID, while John's GUI would be waiting Bill's lock to end. But as soon as Bill was done, John would proceed his booking without ever realizing someone had booked that record already. And so, Bill's booking would be overwritten.
Is this really what the instructions want us to do?