Hi Brian -
Congratulations on your progress with the exam! It can be a long road, but I hope you're learning something from it.
I'd like to respond to some of your thoughts:
1. The true purpose of locking on the record level is to make you demonstrate you know how to do it -- it's a
test, after all.
Seriously though, you can achieve a more efficient utilization of the data store, by reducing the scope of synchronization to the most granular operation that makes sense.
It seems like you've imagined a queue at modify(), after which nothing else can happen. In fact, anything else can happen concurrently -- except another modify() request. So if other connections are being processed outside of this call, they needn't wait for a modify() to complete to do their work. *Only* other modify calls have to wait. Now, in a world where nothing but modify() ever gets called, there's no benefit. Otherwise, you leave the door open for everything else, which can result in a more efficient execution of the program.
2. To really test your understanding of collections, implement delete(). This is a classic example of why you'd want to lock the whole database object, and not just a record, since proper iteration is at stake.
3. A tease hint: Would it make sense that the object that's assigned its lock would know who has it?
Good luck! It sounds to me like you're facing all the right challenges.
-----------------
Michael Ernest, co-author of:
The Complete Java 2 Certification Study Guide
[This message has been edited by Michael Ernest (edited December 19, 2000).]