wood burning stoves 2.0
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
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Design of lock and unlock" Watch "Design of lock and unlock" New topic

Design of lock and unlock

lokesh ks

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
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3632
>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.
Get Certified, Guaranteed!
(Now Revised for the new Pattern)

Your guide to SCJD exam!
Try out the world's only WebCompiler!

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

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..
I agree. Here's the link: http://aspose.com/file-tools
subject: Design of lock and unlock
It's not a secret anymore!