I couldn't understand Max's DVD locking strategy fully. Would appreciate a helping hand here.
It appears to me that Max stores each DVD in a different file but uses only one instance of DVDDatabase/DVDDBAdapter shared by all the clients.(RMI implementation)
Max uses locking for all write operations including the getDVD() method in the DVDDbAdapter class, to retrieve a DVD record.(a read operation). This I presume is to prevent some other thread from writing/reading to the DVD file while a read operation is being performed.
But why is Max synchronizing the instance methods of the DVDDabase class when he has already locked the record?...As each DVD is stored in its own file, isn't it safe to assume that no other thread can access the dvd object file unless they own the lock to the dvd record?
Also DVDDatabase class has this comment: "A DVDDatabase object contains all of the DVDs in the system and operations that act upon the dvds. This class uses serialization to read and write its state. There are also methods provided which allow users to rent or return dvds, add or remove dvds from inventory, and search the DVD database."
I thought this class serialized/deserialized only DVD objects for read/write operations and not itself.I also found a couple of member fields, dbName and recordExtention as transient fields in the DVDDatabase class. I believe only DVD objects were serialized, so what is the benefit of these variables being transient in this class? [ May 18, 2004: Message edited by: Vishwa Kumba ]