• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design of lock and unlock

 
lokesh ks
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
I have certain doubts about my design of the locking an d unlocking .My design of lock and unlock goes some thing like this .
I Have decided to have a lock object for each and every record.
There will be a LockManager which handles all the lock and unlock requests. All the lock requests will be delegated to this lockmanager object which will be a instance member of the data class.And the locks will be stored in a datastructure like a HashSet or LinkedList.
My first doubt regarding the design is:
1. On which object should i synchronize my lock and unlock methods is is the lock object which is availabe for each and every record or the Data structure in which all the lock objects are stored .
2. Should we use timeouts for the threads which are waiting for the access of the database.
3. If we are using RMI,how to recognise a request for lock uniquely ,such that it helps in unlocking the same thread which has locked the resource.
I think this is the most critical part of the assignment and everyone will have a second thought about it before implementing this particular part of the assignment.
I encourage everyone to give me their sugessions regarding this particular topic(i:e lock an unlock).
Toghther we can acheive it
Thanx in advance for your replies(If you wish to reply..)
waiting for your replies
Lokesh
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3776
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>I Have decided to have a lock object for each and every record.
I would say, not a good idea. What if the table has a million records?? For the assignment it might sound ok, but you're not just graded on whether the solution works or not. Your design should also address scalability.
Believe me, there are lot of other better approaches. Think of something else.
-Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus

Your guide to SCJD exam!
www.enthuware.com/jdevplus
Try out the world's only WebCompiler!
www.jdiscuss.com
 
lokesh ks
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Thanx for your Reply.
Do you mean that we should just hold the Record numbers .But how do you hold that in a data structure.???
Again we have to create a wrapper object for the record number and hold it.
Hoping your reply..
Lokesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic