File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread" Watch "Thread" New topic
Author

Thread

Kaushik Badiyani
Greenhorn

Joined: Jun 07, 2001
Posts: 27
Which of the following methods will definetely stop a Thread from running
a) wait
b) notify
c) yeild
d) suspend
e) sleep

What will be the correct answer for above and Will certification test us on depricated methods???
Thanx
Kaushik
Muhammad Farooq
Ranch Hand

Joined: May 08, 2001
Posts: 356
I think a , c, d ,e. The real test will not test on deprecated methods.
Anyone correct me if I am wrong
--Farooq


Muhammad Farooq<br />Sun Certified Programmer for Java 2 Platform<br />Oracle8i Certified Professional Database Administrator
Annie Naqvi
Ranch Hand

Joined: May 04, 2001
Posts: 39
Hi,
Well IMO the correct ans are a,d & e.As yeild may stop execution but that is not guaranteed.
I can't say anything abt real exam but will tell you soon after giving mine
Regards,
Annie.
Kaushik Badiyani
Greenhorn

Joined: Jun 07, 2001
Posts: 27
Muhammad are u sure of it beacuse i perfectly agree with Annie
Jane i need to know ur views on this question

Adam S-R
Greenhorn

Joined: Aug 15, 2001
Posts: 18
I agree with Annnie - yield will only stop thread from running if there is a thread with the same priority waiting to run - cannot yield to lower priority threads AFAIK.
HTH
Adam
Muhammad Farooq
Ranch Hand

Joined: May 08, 2001
Posts: 356
yield() will definately stop the thread from execution and look for any other thread, if there is any other thread it will execute that thread, but if there is no other thread then the original thread will get executed. Here the thread will STOP, then check for another thread, if couldn't fine, execute the same thread, thats what I think.
Any comments,
--Farooq
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
From RHE
A thread that has yielded goes into the Ready state. If any other thread are in the Ready state, then the thread that just yielded might have to wait a while before it gets to execute again. However , if there are no other waiting threads, then the thread that just yielded will continue executing immediately. Note that most schedulers do not stop the yeilding thread from running in favor of a thread of lower priority.
Muhammad Farooq
Ranch Hand

Joined: May 08, 2001
Posts: 356
I am sorry, may be I misleaded you ranchers. I think I have to read the question more carefully, as the question says, "methods that will definetely stop a Thread from running", yield() does not ALWAYS stop the thread .
--Farooq
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

Yah Farooq, definitely was the word we were watching....
------------------
azaman
[This message has been edited by Ashik uzzaman (edited August 19, 2001).]


Ashik Uzzaman
Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread