Originally posted by harcharan kanwal:
Where is your bookFlights method. It should not be in your Data class
And you only wnat to synchronize on the last object possible to keep deadlocks from happening
In our FBN case that is the Collection that holds the list of the locked records, and when you synchronize on that it keeps it for a short time, either through completion or Thread.wait().
Do all databases have a bookFlights method? no they do have a save, but it is generic. bookFlights is more specific to this application so it needs to be in a place that is specific. Like your DataAccessFacade, basically the "middle tier" business logic layer. It is not part of the GUI or the Data, so it is the business logic.
What I mean by last object to synchronize, I am talking about the HashMap, in the lock or unlock methods, not in modify.[/QUOTE
The following is my LockManager class
Lock manager class get instantiated in the Data class,and lock and unlock methods are implemented as it is in the topmost post of this thread.
i have the following confusion
what is multiple clients access
1.is it when i synchronized the bookFlight method , and allow only one client at a time to enter to lock ,read ,modify and unlock operation.but then i think where is the need for to lock the record ,when i am not allowing another client to even enter the method body of bookFlight.
2.if i do not synchronized on the bookFlight at the method level, then i am allowing multiple clients to enter the in the methods,but then with each client enterance ,it brings in different values of clientID,numberOfSeatsToBeBooked,recordNumber.This will cause the corruption of the data or deadLock,no matter what part of the method is synchronized.
The only thing that works right now is the solution number 1 i.e synchronized at the method level,but then to me it does not seems like multiclient opertion or it is.
put some light on it, i am stuck thinking of it.