Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sleeping threads!!!!

 
Gazala Bohra
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Anshuman Acharya
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the link is not working, jane
 
Shaibaz Gadhwala
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Shaibaz,
Thanks for clearing the confusion finally.And never mind about the mistake.It is human to make them.
Thanks again,
Gazala.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic