I am facing a very interesting problem and struggling to find an answer. The problem starts form the fact that i am assuming that in local mode the GUI is being run on the server and so at one end the server is being used as a local database server and on the other hand it is being used as a remote database server. Now the problem arises from the fact that when i start the remote server on the server machine and i start the gui on it too, these two are being run in two differnt virtual machines and thus how do you provide locking in such a scenario. Any help in this scenario will be highly appreciated. Gaurav Kalra
I thought on this too - but it seems impossible to have a locking which can cater to both the local and the server clients - As server clients would use one object of the Data class and the local client would use another. There is no common meeting place for the two except in the Database file - ( just for trial - try marking the record which has to be locked - just as a deleted record is marked). Then I re-read the instructions and found that Sun expects the user to be EITHER in local or networked mode. So I have used locking for networked mode only. Pls. also shed light on how are you planning to inform the Client that his thread is waiting - if the record is locked.
according to the assignment instruction, in local mode, the databae and user interface should run in the same VM and no networking is performed, and no sockets(RMI implemented in sockets) should be created. So, excepting you put lock status in db.db file, the lock/unlock mechanism will be no use in local scenario.