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

Locking Question

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I have not yet nailed my design down. But I was just looking at some of the locking design post and I wanted to know why everybody is modifying the public void lock(int record) to public void lock(int record, Object clientID). I mean do we really need to know which client locked it?? All we need is a hashMap that has an entry for the record number. If the record number exist in the HashMap then we know that somebody has locked it and we cannot unlock it and hence we need to wait.
Also lets say if the client that locked the record died then in that case we can also put in the hashmap the timestamp that the client locked the record. We can then have another thread run which iterates through the hash map and compares the timestamp in the map with the current timestamp if it is older than xx seconds then we can remove that record number from the hash map.
Any suggestion and comments???
Thanks
 
Juan Ec
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as it has been said before, two situations should be controlled
- client A can not ask to lock a record already locked by him (if so: do nothing)
- client A can not ask to unlock a record locked by client B
first one is explicitly required in the assignment and second one becomes necessary if we don't want to make just trusted clients.
so you see someway to identify clients is necessary
for dead clients, different solutions have been also discussed: the one you talk about, implementing 'unreferenced' interface, using Timer ...
[ October 12, 2002: Message edited by: Jaun Katabasis ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic