• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Marcus Green exam 2

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think so too.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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



------------------
 
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Is this the real life? Is this just fantasy? Is this a tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic