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

Thread Q from jexam

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following will definitely stop a thread from executing:
wait()
notify()
yield()
suspend()
sleep()
the answer given is a,c,d,e
but how come c. if there is no other thread then it wont stop the thread .. and the resoning given was

Only notify() will not explicitly stop an executing thread from running. Yield() returns control back to the JVM, which may or may not stop the thread from running.

( so its no definite )
if the Q was whcih of the following can stop the thread then yield() is one of the answer ..
correct me if i am wrong ..
anil
 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tend to agree with you anil, but I think what they are saying, is that yield() will stop the thread and move it into the ready state, and then if no other threads can start then it will be put back into the running state. So basically it does stop it for a while. But I don't like the question much.
Bill
 
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic