Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Marcus Green exam 2

 
quan zhu
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think so too.
 
Golam Newaz
Ranch Hand
Posts: 64
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 625
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2813
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic