• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Design of lock and unlock

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Enthuware Software Support
Posts: 4810
52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic