aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread Question" Watch "Thread Question" New topic
Author

Thread Question

Fes D Gaur
Ranch Hand

Joined: Apr 29, 2005
Posts: 54
A Mock test had the question:

Which of the following will definitely stop a thread from executing?

yield() was one of the answers. I know that yield() sends control back to the JVM and the JVM may pick up the same thread and start it again. So this questions is somewhat confusing. Could a question like this come on the Test?

Thanks,
Fes
Gokul Somasundaram
Greenhorn

Joined: Jul 17, 2005
Posts: 20
Please post the question and all the choices.
Akshay Kiran
Ranch Hand

Joined: Aug 18, 2005
Posts: 220
Originally posted by Fes D Gaur:
A Mock test had the question:

Which of the following will definitely stop a thread from executing?

yield() was one of the answers. I know that yield() sends control back to the JVM and the JVM may pick up the same thread and start it again. So this questions is somewhat confusing. Could a question like this come on the Test?

Thanks,
Fes


Not a good choice. what if there are no other threads waiting for the object lock? in that case, the same thread will obtain the lock (reentrant) and execute happily.
Thread.stop() is one, it is however deprecated. Thread.interrupt() would be a good choice, and maybe Thread.sleep() << but this one I'm not sure, because if it is sleep, it is still executing a command isn't it? not practically, but yes.


"It's not enough that we do our best; sometimes we have to do<br />what's required."<br /> <br />-- Sir Winston Churchill
 
 
subject: Thread Question