• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

lock and client

 
Suchak Jani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been reading some of the posts here on record locking and the need for identification of the client who has the record locked.
I am trying to understand why?
I mean lets assume that i write the client code and it looks like this :
manager.lock(recordNumber)
//write to db
manager.unlock(recordNumber)
Also Assume that the above is in some kind of synchronized block.
So if a thread wants to write to the db it gets the in the synchronized block and gets the record locked. Then it writes to db ,releases the lock gets out of the synchronized block. Now another thread can get in the synchronized block and do the same thing.
So when i write the client like that what is the need for me to know who the client is.
Thanks in advance.
Have a pleasent day!
Suchak Jani
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could a rogue Client call unlock() with a record number that it does not have a lock on?
That is the specification by Sun. If you can guarantee that, and can argue it in your design.txt and essay exam then you "should" be fine. I can't even guarantee that. But there are some here who never used a client ID, and passed.
Mark
 
Suchak Jani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark
Thank you so much for the reply.
Regards
Suchak Jani
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic