But then, if 3 clients all request hotels in Smallville, doesnt that mean that none of them will be able to book a room, since all the records will now have read locks by all the clients?
In the section of code where you handle checking if the room is still available, is it possible to check the other fields for changes as well?
I was considering an initial "show all rooms" query.
I was thinking of allowing multiple read locks (say a count that increments and decrements) and then a write lock waiting until the read lock count (for the record of interest) was zero.
Does anyone know has "real" databases do this?
I keep thinking, 80 points... thats a lot of points for a sprinkling of synchronized, one call to wait and a couple notifyAll?
Does this mean that every record in the database would then have a read lock applied?
Do you handle releasing locks if a client dies (or even just shuts down without clearing locks)?
If the specified record is already locked by a different client, the current thread gives up the CPU and consumes no CPU cycles until the record is unlocked.?
I've noticed a few posts on unreferenced and WeakHashMaps. I was thinking my client just calls a single bookRoom method (using RMI) on my Data adapter class, that runs on the server.
I've tried killing the GUI in the middle of this (by adding a sleep in the modify) but the bookRoom always completes, so always releases the lock. Am I missing something?