• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Locking question

 
No�l Verdurmen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a design for locking and I wonder if it is correct. It seems so easy.
I got the feeling I missed something:

At serverside, there are multiple data objects. There is one static HashMap that contains the locked records. In lock(recNo) I synchronize on the HashMap, lock the record if possible by writing it in the HashMap.

If the cookie is unique, I feel I can execute update and unlock without synchronizing anything. To recover from failure, I catch an InterruptedException and maybe remove the logical lock from the HashMap.

Is this correct? Thanks,
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No�l,
How will you deal with more than one client trying to lock the same record at the same time?
Remmeber that non synchronized methods are non atomic.
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi No�l, You might be interested in Andrew's posts about synchronzing threads and locking records here and the second post at 5:10 PM here
[ September 08, 2004: Message edited by: Marlene Miller ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic