• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

threads - maha and khalid cross

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which methods may cause a thread to stop executing?
1 sleep();
2 stop();
3 yield();
4 wait();
5 notify();
6 notifyAll()
7 synchronized()
Select all correct answers.
the correct answers are 1,2,3,4.
but in khalid it is given clearly as "calls to methods suspend(), sleep() and wait() do not stop a thread..they only cause the thread to move out of its running state. a thread will stop only when it is done executing the run method"
which one is right...please answer me
gayathri
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi gayathri
i think that the answers are right, when a thread executes, it is in the running state, so it is in the run() method, those methods may cause the thread to stop executing, taking it out of the running state, meaning stopping it from executing the run() method.
'stop executing' doesn't mean thread is dead!
anyone pls correct where i'm wrong
 
Beauty is in the eye of the tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic