• Post Reply Bookmark Topic Watch Topic
  • New Topic

lock-modify -unlock  RSS feed

 
Prakash Krishnamurthy
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A semaphore around lock-read-modify-unlock defeats the purpose of the lock, there is no need whatsoever of that outer synchronization.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!