SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
1- Regarding the lock cookie,all the assignments I know about
the lock cookie is required.I also did Bodgitt and Scraper and there is a
lock cookie requirement.
3- As i understood from your code, is that you throw a run exception
if a thread waits more than 7 seconds.Actually a thread waiting for
a lock on a record can wait more than 7 seconds.
4- In your lock method,after the thread gets the lock on the
locks object again, you assume that the lock on that record
is released. This is not the case.
in my spec it time out even forbiden: "consuming no CPU cycles until the desired resource becomes available"
Originally posted by james bonds:
Cookie doesn't exist in my assignment.(Urlybird 1.3.1 version)
Vince<br />SCJP(1.4), SCWCD(1.4), SCJD (5.0)
Personally I think that Unreferenced and WeakReference are elegant solutions. I dislike time-outs within the assignment, as I don't believe the instructions allow for them.Originally posted by James Bonds:
I also think that Time-out is bad idea than Unreferenced or Weakreference.
But, I think that is nothing like as bad as removing it. Am i right ??
True, but as mentioned multiple times in the book, the sample instructions that we followed in the book are deliberately different from the instructions given by Sun. If we did not make our instructions different, we would be giving away a solution. Our instructions specifically stated that a lock should be held no more than 5 seconds.Originally posted by James Bonds:
The locking method of Monkhouse book is just 5 second.
Unfortunately you didn't get to see the complete code - we do return false (yet another difference from the real assignments) if we fail to get a lock after 5 seconds.Originally posted by Maciej Miklas
In my opinion example of your book does not have a time out. It weak every 5 seconds to see if the record is free. If not it goes sleep.
Good point.Originally posted by Maciej Miklas
I would not do that, specially that my specification says: �consuming no CPU cycles until the desired resource becomes available� and this is not the case.
That is part of the challenge of the assignments that do not have cookies. There are multiple solutions, including:Originally posted by Vincent Li
Yes, but how do you identify the caller to "unlock()" is the original owner who called the "lock()" method [without a cookie]?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |