Hi everyone, I came across a question in the Jquest stimulated exam in which the two correct answer options confused me, can anyone explain to me if this is true.The correct options were: a) When the thread "goes to sleep" it releases the lock on the object. b) The "sleeping" threads always have the lock on the objects. What confused me was that these two options seem to be exactly opposite so how can both of them be true. Can someone please enlighten me. Thanks, Gazala
Anshuman Acharya
Ranch Hand
Joined: Jan 19, 2001
Posts: 144
posted
0
i will check in a moment but answer (a) seems wrong to me. by thread "gonig to sllep" we obviously mean a call to static method sleep(long), which does not release the locks on any object. the only way to put the thread in a waiting stage with the release of the locks is the wait() method. i will say that this is a erratum
bala G
Greenhorn
Joined: Jan 15, 2001
Posts: 6
posted
0
HI I think the questions are OOPS concept oriented & not java oriented SO perhaps 1 means that A object invokes yield() Or wait().Then both are correct . Anybody what do u think?
Jane Griscti
Ranch Hand
Joined: Aug 30, 2000
Posts: 3141
posted
0
Hi Gazala, See this earlier discussion on the same topic: link to discussion link should now work Hope it helps. ------------------ Jane Griscti Sun Certified Java 2 Programmer "When ideas fail, words come in very handy" -- Goethe [This message has been edited by Jane Griscti (edited January 23, 2001).] [This message has been edited by Jane Griscti (edited January 23, 2001).]
Hello Gazala, I'm the creator of JQuest Mock Exam and while entering the answer into the database the error was commited on my part. If u c the JDK API then you would see that a thread never releases a lock on the object while it is sleeping. However the answers mentioned were in total contradiction. I'm extremely sorry for the inconvenience caused to you. A new version can be downloaded from http://jquest.webjump.com
Gazala Bohra
Greenhorn
Joined: Oct 27, 2000
Posts: 27
posted
0
Hello Shaibaz, Thanks for clearing the confusion finally.And never mind about the mistake.It is human to make them. Thanks again, Gazala.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.