Originally posted by Andrew Monkhouse:
I think the answer to that would be getting well outside of the scope of this assignement.
However the basic answer is the amount of space required for all these locks.
If you have 20 tables to lock, each with 100 records, you will be allocating space for 2,000 key / value pairs plus any class overhead.
Not sure I'm following you here Andrew: this method doesn't require that you keep track of unlocked records. Thus, with 2,000 potential locks, the actual amount of lock obtained at any one time would be, by defination, the minimal number needed. That is, it could be 1, or 10, or 2000. This is consistant with any other approach, I would think.
All best,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
Originally posted by Rajesh Rajesh:
Hello Max,
I posted the above after testing for add() only. But your idea works perfectly fine for delete(), modify(), lock(), unlock() and all methods of Data (except add()) for 200+ multi threads. There was no errors.
The add() operation error is not because of Max's principle. I tried to add() from several threads and above error popped up. Although add() is not for assignement, its lack of support for multi threads persists. Will not solving add() reduce marks???
If the question in essay exam asks how do you plan to upgrade Data for more than one database, the answer would be to have a static Map for every Database. Is this practice of having a number of static maps a good practice?
Rajesh
Andrew:
If you have 20 tables to lock, each with 100 records, you will be allocating space for 2,000 key / value pairs plus any class overhead.
Max:
Not sure I'm following you here Andrew: this method doesn't require that you keep track of unlocked records. Thus, with 2,000 potential locks, the actual amount of lock obtained at
any one time would be, by defination, the minimal number needed. That is, it could be 1, or 10, or 2000. This is consistant with any other approach, I would think.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
How much does 512Mb memory cost?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Qusay
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Originally posted by Andrew Monkhouse:
Hi Qusay,
You asked: How did you pass mapLocks to Data class?
I think this thread has been discussing having a LockManager class which handles the specifics of the locking for us. So the Data class never gets a copy of the mapLocks object.
Regards, Andrew
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|