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 Marcus Green exam 2 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 "Marcus Green exam 2" Watch "Marcus Green exam 2" New topic
Author

Marcus Green exam 2

quan zhu
Greenhorn

Joined: Dec 14, 2000
Posts: 27
22)What can cause a thread to stop executing?
1) The program exits via a call to System.exit(0);
2) Another thread is given a higher priority
3) A call to the thread's stop method.
4) A call to the halt method of the Thread class
the answer is: 1,2,3
Is 2 correct? I thought it will depend on the platform.
Thanks
Deepak Jindal
Ranch Hand

Joined: Nov 16, 2000
Posts: 30
I think so too.
Golam Newaz
Ranch Hand

Joined: Jan 08, 2001
Posts: 64
Hi,

Normally, sleep(), yield(), stop() and wait() methods will
stop Threads from executing. And 2 is correct because wait(),
notify() and notifyAll() are inter-related and when notifyAll wakes up all the threads that call wait on same object. the highest priority thread that wakes up will run first. So
calling highest priority thread you stop Threads,
- Golam Newaz
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
Golam,
I don't see your point. The question doesn't say anything about the methods that you mention. It simply states that when another thread is given a higher priority, then that'll stop the current thread from running. I agree with Deepak and Quan, that it'd depend on the platform since on a time-splicing platform, priorities really don't matter. If anyone else can shed light on this please do.
Michael Burke
Ranch Hand

Joined: Jul 29, 2000
Posts: 103
You're right that answer #2 depends on the platform. The question asked what can stop a thread from executing not what will stop it. In other words answer #2 in some cases will be a correct answer.
Sai Ram9
Greenhorn

Joined: Feb 13, 2001
Posts: 18
Yes answers 1, 2, 3 all are right . Though the stop() method is deprecated it still can cause a thread to stop executing.
sher singh malhotra
Greenhorn

Joined: Feb 15, 2001
Posts: 1
Originally posted by quan zhu:
22)What can cause a thread to stop executing?
1) The program exits via a call to System.exit(0);
2) Another thread is given a higher priority
3) A call to the thread's stop method.
4) A call to the halt method of the Thread class
the answer is: 1,2,3
Is 2 correct? I thought it will depend on the platform.
Thanks


------------------
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
I intend to modify the answer to this question to emphasise that the question asks what CAN stop a thread executing, rather than what WILL cause a thread to stoop executing. See how asking a good question can not only help yourself but help future browsers of that web page. Cool!
Marcus


SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Marcus Green exam 2