SCJP 5, SCJD 5, SCWCD 5, SCBCD 5, SCJDWS 5
My SCBCD-Notes - OCMJEA 6 notes
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
SCJP 1.2; SCWCD 1.2,1.4; SCBCD 1.3; SCJD 5.0
The locking-strategy is based on the two classes Facade.java und Implementation.java. Facade.java implements the interface DBAccess.java and so has to provide the locking methods. But the really locking logic is in the class Implementation.java, and the Facade.java forward only the request of locking and unlocking to the class Implementation.java. The Implementation.java has a map<Long, Long> which contains all the locked record(-numbers) with their cookie. To lock a record, first the map will be checked, to see if the specific record-number still locked by another client. If it this is the case, than the thread will go into a waiting state. After the locked record is unlocked, all waiting threads will be notified and check again if they can now lock the record. If this is the case, than the lock method will lock the specific record over the record-number and will return a cookie. It is now only possible to modify the record if a Thread knows the specific lock-cookie.
Further I synchronzied all the methods which directly access the Database-Fiel over a RandomAccessFile-instance
SCJP 5, SCJD 5, SCWCD 5, SCBCD 5, SCJDWS 5
My SCBCD-Notes - OCMJEA 6 notes
SCJP, SCJD
SCJP 5, SCJD 5, SCWCD 5, SCBCD 5, SCJDWS 5
My SCBCD-Notes - OCMJEA 6 notes
Originally posted by Christian Nicoll:
Hi Jethro,
your advice is absolut correct and I've did that too. I forgot it to wrote about it in my above locking-strategy.
My both lock- and unlock-methods of my Implementation.java class surround the whole code of these methods with a synchronized statement like this:
Best regards,
Christian
[ July 29, 2008: Message edited by: Christian Nicoll ]
Originally posted by Christian Nicoll:
[QB]Hi Jethro,
your advice is absolut correct and I've did that too. I forgot it to wrote about it in my above locking-strategy.
My both lock- and unlock-methods of my Implementation.java class surround the whole code of these methods with a synchronized statement like this:
SCJP, SCJD
SCJP 5, SCJD 5, SCWCD 5, SCBCD 5, SCJDWS 5
My SCBCD-Notes - OCMJEA 6 notes
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|