• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Abt Threads

 
Ranch Hand
Posts: 643
  • 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. yield();
3. wait();
Ans is 1,2

why not 3.
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeild() is just REQUEST to JVM . It is upto JVM to execute the request or not.
So in the end behaviour is not determined . so we cannot exactly say that when yeild() is given thread stops from executing.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tell us where the question comes from. What mock exam?

Could it be that the author of the question thinks the reason is some bizzare one "like wait() is not a member of the Thread class?"
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by babu sharath:
yeild() is just REQUEST to JVM . It is upto JVM to execute the request or not.
So in the end behaviour is not determined . so we cannot exactly say that when yeild() is given thread stops from executing.



Well the question does say "may", not "will".
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic