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