"What you don't know, can't help you"
SCJP (81%), SCWCD (81%), SCJD (354/400), SCBCD (85%)
First, I use a Set instead of a List as they do in the book. IMHO, we deal with an unordered collection without duplicates, so a Set is the better option. Or do I still miss anything ???
Second, I still have no implementation of "locking the whole database" when the value of -1 is passed.
What is a good way to implement this ? The lockedRecords variable only contains record numbers. Filling it up with all record numbers present in the DB is possible, but maybe a more elegant option is available.
......
One question: do you think that the call to notifyAll() is useful? And if "yes", how would you justify it?
Regards,
Phil.
"What you don't know, can't help you"
SCJP (81%), SCWCD (81%), SCJD (354/400), SCBCD (85%)
Originally posted by Klaas van Gelder:
In the lock method, on my second thought, there indeed appears to be no reason to notify the other threads waiting [...]
But Habibi tells a different story ! In his eample, notifyAll IS called in the lock method.
Originally posted by Klaas van Gelder:
Furthermore, it is indeed possible to save some extra info with the locked record, thus using a Map instead of a Set. In some examples on this forum, they save the client ID and check this ID when trying to unlock the record. But is there ever a situation that a client tries to unlock a record which he did not lock ? Habibi says in his example that he ignores the very small chance that this happens...
Originally posted by Klaas van Gelder:
And about locking the whole DB,
Indeed it is explicitly required to lock the whole DB when passing the value of -1, but the specs document does not tell when this should happen...
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Klaas:
And about locking the whole DB,
Indeed it is explicitly required to lock the whole DB when passing the value of -1, but the specs document does not tell when this should happen...