if i use "one lock to control them all" i'll waste CPU every notifyAll when i wake up all threads waiting for all records.
if i use one lock per record then i'll need N locks (N is the database size) or conditions (it doesn't matter, it's still an
object after all) because there's no way* to clean up a lock when not needed and at some point N locks would exist.
so in short: CPU vs. RAM, who win?
(or there's no straight answer for that?)
*at least not that i found and is guaranteed AND NOT SUPER COMPLICATED FOR THE ASSESSOR
yeah originally I had the lock handover situation as described in the SCJD by Monkhouse but it was a bit more complicated than having 1 lock that rules them all, so for sacrificing more CPU cycles for simplicity I went with the latter implementation, note it does state in the assignment that the software should be understandable by a junior programmer which in essence is true to the fact in a real world scenario, every heard of the KISS principle? plus I think with commodity hardware getting faster all the time simplicity can rule in the majority of cases
I am currently doing the SCJD myself just wanted to do an 'unselfish' post for a change & as you see Roel who replied to your post has indeed been quite insightful with posts related to questions i had cheers Roel, ok digression over :P