This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Design of lock and unlock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Design of lock and unlock" Watch "Design of lock and unlock" New topic
Author

Design of lock and unlock

lokesh ks
Greenhorn

Joined: Apr 29, 2001
Posts: 5
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

Joined: Sep 23, 2000
Posts: 3255
    
    2
>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


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
lokesh ks
Greenhorn

Joined: Apr 29, 2001
Posts: 5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design of lock and unlock
 
Similar Threads
My Locking Approach
Passed with 95%
Record locking must be implemented using the methods public void lock(int) and public
LockManager as member of Data object
Mark Spritzler/ Max H/Andrew Monkhouse: please comment on the holes in my design