Hi guys!
Please, help me! Sorry for my English.
This is my view of problem and my question:
1)Max's book example has DVDDbAdapter class to lock .DVD file before process any operation with this file.
Lock file in this example means : dont allow 2-d access to this file while some client access(locked) it.
Each record saved in different file so lock record means lock file.
Only find operation don't demand locking.
Static vector consists off UPC numbers(locked files names)to synchronize access from different clients and from different methods of any one client.
So system works like this:
StartAnyMethodOfAnyClient->takeLockOnWholeFile->DoJob->rleaveLock->endMethod
Using RMI don't change anything, cause every method call must take file lock.
Is this all right?
2) Sun's Contractors project has only 1 DB file, so this is some different situation...All records within one file...
Suppouse I use one Instance OF RandomAccessFile(RAF) for every client, so when client connect to DB he create RAF instance(Need I synchronize it, make static?). When I use RMI even one client can access this instance from 2 threads, even during one method invocation. So I MUST(?question) lock DB file for every method invocation of every client as we did in Max's example?And releave lock at the methods exit?
Or it's possible to lock only some record in the file?
Please, help me , I need any idea.