In my assignment, the interface has the methods: lock(), unlock() and isLocked(). So I assume they must be used by the client. Is that correct?
If so, I imagine that the client will first call the isLocked() method as a while condition. When the desired record becomes unlocked (the while finish), the client will call the lock() method.
But between the finish of the while, and the call to the the lock() method, another client can get the lock for the record.
How can I ensure that nobody is going to get the lock for the desired record between this two operations? I can't just synchronize in the client...
EDIT: Now, reading more carefully, I noticed the instructions say that the lock method does all this wait-while-is-locked-and-then-lock work.
So, I'll change my question... For what did you guys used the isLocked() method?
Your more careful reading of the instructions is spot-on: lock-method is indeed responsible for "waiting while record is locked and lock when record is available". The isLocked is not used in my application (just like I didn't use delete and create methods), but I provided an actual (working) implementation for these unused methods.