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

Locks implementation in general

 
Michael Wiezik
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
My question is rather general - how to implement locking on objects? Should locks be implemented as objects, as it is in hibernate, or each persistent object should implement some interface for locking? I need some clues about general architecture as I just start SCJD. Any help would be helpful.
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michal,

You can use any design you like for locking. There is not particular best solution.

However, most mechanisms described in this forum use one of these methods:

  • Create an object representing a record. This object has a variable and/or methods that manage the lock state of that record. You need a collection of such objects, such that each record has an associated lock object.
  • Create a collection that contains record numbers. If a record number exists in the collection, the record is considered locked.

  • HTH,

    Frans.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic