SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
After working on it for a while, I believe that two clients can't own a lock on the same record at the same time, however the rest of Henry's comments still apply.
You are quite correct - if it can be proven that there is any way that two clients can own the same lock, then the code fails.Originally posted by Henry Wong:
I believe that it will be very unlikely to almost impossible to ever see two threads own the same lock, at the same time, but IMHO, the issue isn't whether it will happen under current conditions, but can it happen under any condition? However, unlikely?
In the SCJD assignment, this is not the only protection - the update and delete methods both require the lock cookie to be provided and valid. So the particular record is safe.Originally posted by Henry Wong:
Also, what is the difference between two threads believing they both own the lock, and actually owning the lock? This is the only protection for the record, so if two threads believe they own the lock, it is just as bad.
Correct me if I am wrong, but doesn't your condition start with the requirement that both thread A and thread B own the same lock?Originally posted by Henry Wong:
Anyway, here is my very unlikely condition that will yield two threads owning the lock...
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
All the code presented assumes that the record is active - Khaled throws an exception whenever isActiveRecord returns false.Originally posted by Henry Wong:[/QB]
Later, it is assume that the record will be changed to active.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
What do you advice "Barry Gaunt" since you may have direct interaction with Sun.
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
"I'm not back." - Bill Harding, Twister
SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
"I'm not back." - Bill Harding, Twister
Regardless whether i am right or not (probably i am sure of my code).The messages describing were i lost most of my points should be more descriptive.Since one of the main objectives of getting Certification is to learn, I expect from Sun to give more information about why my record locking mechanism is not safe and to be more professional than that.I expected a more professional way in assessment.
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
and if you don't know it, you get a poor grade
Would you then mean none of them are professional?
SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
Consider Paul's rocket mass heater. |