wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes About current thread yielding on searching for locked record Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "About current thread yielding on searching for locked record" Watch "About current thread yielding on searching for locked record" New topic
Author

About current thread yielding on searching for locked record

cody monk
Greenhorn

Joined: May 15, 2011
Posts: 6
Hello ranchers, my assignment said "Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU" but the lock() method in DB interface said "the current thread gives up the CPU and consumes no CPU cycles until the record is unlocked". On one hand, because it says "should" I don't have to do it. On the other hand, as it is listed in the face, I have to do it.

So my question is: of course we have to implement the interface methods, but do we have to conform to the behavior described in the comment of the methods? Does anyone who passed the exam and didn't implement this behavior?

Thank you.
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2266
    
    3

Howdy, Cody!

Well, the instructions say that the interface must be implemented, so I'd say it isn't a good idea to not do what the comments say.

About the "should cause the current thread to give up the CPU" stuff, I'd read it as a must: if the current Thread doesn't give up the CPU, then I really think this can cause automatic failure.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5451
    
  13

I even want to add: I know about just a few people who failed and the reason was every time because the current thread wasn't given up the CPU when a record was already locked. So my advice would be: if you want to pass the certification without having to resubmit, implement the interface according to the behavior described in the comment.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: About current thread yielding on searching for locked record