Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The ReservationsManager Class In Monkhouse Book

 
Merlin Chen
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the ReservationsManager class(Page 154,Topic:Creating Our Logical Reserve Methods)
it has there variables:





---------------------
And a part of reserveDVDMethod :



At the beginning of the method,it already has the lock.
but in the if statement it calls the await() method.Which lock
is the thread waiting for?
----------------------------------------------------------------
In the description of the reserve method,it says:
We have decided to allow any UPC to be reserved, even if no such record exists. This ensures that a DVD can also be reserved when we are first adding it to the system.
If the DVD not exist,how can we reserve it?I was really confused.
[ August 25, 2007: Message edited by: Merlin Chen ]
 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

the second lock (i.e lockReleased.await()) you are waiting until signaled in the releaseDvd() IF UPC is already reserved.

regarding your other part of the question:
how do you reserve: by adding the upc to the reservations HashMap, so that doesn't require the existance of the upc in the DB. now if the record is new you are adding the upc of the new record to the reservations (to lofically lock it), which means that you don't want to allow others to reserve this upc until you are done.

hope that helped
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic