• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic