After the dblockPending flag is set, any client requesting to lock a record would cause an exception to be thrown.
I did the same ting, except that instead of throwing an exception, the
thread wait()s until the flag is unset. The entire code to implement lock manager (including record lock/unlock and database lock) is just 26 lines of code in my implementation, and since the subject line is about elegancy, I think that the code
is more elegant than
However, these two code segments implement the different design decisions, -- the first one passively waits until all records have been unlocked (while not allowing to lock new records), and the second piece of code acts just
like another client, locking one record at a time. I would say both decisions are perfectly acceptable.
Eugene.