This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes sleeping threads!!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "sleeping threads!!!!" Watch "sleeping threads!!!!" New topic
Author

sleeping threads!!!!

Gazala Bohra
Greenhorn

Joined: Oct 27, 2000
Posts: 27
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
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
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
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).]


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Anshuman Acharya
Ranch Hand

Joined: Jan 19, 2001
Posts: 144
the link is not working, jane
Shaibaz Gadhwala
Greenhorn

Joined: Jan 22, 2001
Posts: 11
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
Hello Shaibaz,
Thanks for clearing the confusion finally.And never mind about the mistake.It is human to make them.
Thanks again,
Gazala.
 
jQuery in Action, 2nd edition
 
subject: sleeping threads!!!!
 
Similar Threads
Confustion in threads again !
sleep() method concept
A Thread question from JQuest
synchronization - cannot wake a sleeping thread?
static and instance methods