• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Releasing locks

 
David Winters Junior
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,

I have decided to adapt a locking solution as follows:

I have a seperate LockManager class to handle locking records so that only one
client can modify a record at one time.

In my Lock method i use a solution similar to Andrew MonkHouse whereby each client wanting to modiy a record will wait for a specific condition to be triggered.

i include here andrew's code from his book for the reserve lock method



I have completed the following code for the release lock counterpart of this method in the lock manager class and it works okay with the tests i have completed.

I am looking for some feedback here on what one thinks of this code, is their any issues with it as far as one can see:



Your input would be appreciated

David
 
Roman Yankin
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David, honestly this approach is way too complicated, why don't you have just one ReentrantLock and just use lock()/unlock() before/after every operation that requires synchronization?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic