This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

lock-modify -unlock

 
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic