File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Monkhouse DVD example: 2 levels of locking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Monkhouse DVD example: 2 levels of locking" Watch "Monkhouse DVD example: 2 levels of locking" New topic
Author

Monkhouse DVD example: 2 levels of locking

Musab Al-Rawi
Ranch Hand

Joined: Aug 06, 2007
Posts: 231
hi,

in the Monkhouse DVD example (by the way it is such an orgnized and easy to follow book, thanks Monkhouse) we can find 2 levels of locking:
1. db layer, that's when we have to acquire a lock (could be read or read/write lock) before we do any operation depending on the operation.
2. inside the reservation manager, which provides logical locking.

now as a class we can't really reach to the database without going throw the facade, which gives us the ability to logically lock records before dealing with them.

so why would we still need the DB lower-level-locking (the frist one) if we are using the logical higher-level-locking anyway ?


SCBCD - SCWCD - SCJD - SCJP - OCA
John Stone
Ranch Hand

Joined: May 04, 2007
Posts: 332
thread 1 is going to write at offset 8:
RAF.seek(8);

then thread 2 jumps in:
thread 2 is going to read at offset 5:
RAF.seek(5);
RAF.read();

and then thread 1 continues:
RAF.write() -> but the offset is wrong
[ August 29, 2007: Message edited by: John Stone ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Monkhouse DVD example: 2 levels of locking