When a client is booking a record and following the lock-modify-unlock sequence, inorder to prevent two clients making a change to the database the same time, I am synchronizing it. I think I need to do this because I need to query the database for the avaliable seats just before modifying it, and 2 or more clients doing this at the same time will pose a problem.
I am also making that class (booking agent class) a singleton class so that there is only one instance of a booking agent. Does this sound alright? Can this be done in a easier way?
posted 14 years ago
A semaphore around lock-read-modify-unlock defeats the purpose of the lock, there is no need whatsoever of that outer synchronization.