SCJP 1.4<br />SCJD 1.4
Am I going in the right direction or am I missing something big? I want to avoid failing at any cost, and especially the dredded 44/80, though sometimes I wonder if it is inevitable.
![]()
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
SCJP 1.4<br />SCJD 1.4
Anton Golovin ([email protected]) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
Thanks for the reply, Anton. In my delete method, it actually calls unlock before deleting the record. I questioned whether a scenario could happen where I run delete, and then delete calls unlock before deleting the record, and then a thread locks that record which is about to be deleted. However, it can't happen because all three methods are fully synchronized. What do you think?Originally posted by Anton Golovin:
Hi, Daniel!!
Good to see you are completing your assignment. I wish you best in passing it. I think that if you make sure that not only your lock/unlock works, but also that your create method is implemented so it does not cause any problems. Consider the following situations:
two or more threads call create method simultaneously. a thread is running the create method while another is hypothetically running lock-delete-update-unlock, and the create method cuts in between delete and update.
This should force one to think about various issues with their locking implementation. The create method should not reuse deleted records while they are still locked, for instance.
This raises another possibility. What happens if two create methods determine the same record number to be reusable while it is locked? I would suggest avoiding this situation completely because then you will have to write into your create method some pretty complex logic to avoid different threads overwriting each other with the create methods. I would suggest the create method should find a non-locked deleted record and overwrite it.
Also, test your lock method. Does it always protect your code from mistakenly operating on non-existing records?Could there be a situation when it passes control to the next method in your locking chain when it should not?
[ January 08, 2005: Message edited by: Anton Golovin ]
SCJP 1.4<br />SCJD 1.4
If we use unferenece, how do I detect a clientID? If each client gets its own Remote instance using a Connection Factory when doing a remote lookup, how do I identify that client.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
What are you doing? You are supposed to be reading this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|