• 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

Thread yield() method question

 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,

This question is from Marcus Greens' examulator.com

What can cause a Thread to stop executing?

1 Calling the yield method of the instance
2 Calling the yield method of another thread
3 A call to the halt method of the Thread class
4 Another thread is given higher priority

ANSWER:
4) Another thread is given higher priority

Options 1 and 2 are incorrect because the yield method is static and belongs to the class itself and not any instance of the class. The Thread class does not have a halt method.
====================

Isn't option1 also correct?

[thought, reference can also be used to call the static yield().....]

Thanks
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
we can call yield on an instance (as static methods can be called on instances also) but it may have no effect.
 
Everybody! Do the Funky Monkey! Like this 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