This week's book giveaway is in the Open Source Projects forum.
We're giving away four copies of Eclipse Collections Categorically: Level up your programming game and have Donald Raab on-line!
See this thread for details.
  • 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:

Marques exam 2, q 22

 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question 22)
What can cause a thread to stop executing?
1) The program exits via a call to System.exit(0);
2) Another thread is given a higher priority
3) A call to the thread's stop method.
4) A call to the halt method of the Thread class
//ANSWER ALSO INCLUDES 2, HOW IS THIS TRUE SINCE A PARTICULAR PLATFORM HAS NOT BEEN SPECIFIED IN THE QUESTION, IF THE PLATFORM USES TIME SLICING, THEN 2 HAS NO MEANING ??
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually it does. I agree there's some subtleties here. First of all it's not only platform, but also the JVM implementation green or native threads plays important role here. In case of classic green thread JVM 2 is correct on any platform (which is probably is assumed by the test). In case of native thread Win 32 JVM it is also correct, VM will make every possible attempt to preemt a thread with higher priority and time slising has nothing to do with this (well, keep in mind that Java thread priorities do not usually map directly to native thread priorities, he-he, so two threads of different Java priorities may be actually of the same native priority, so no preemtion will happen!). In case of native thread Solaris JVM it's thrue that you can have two or more threads of different priorities being timeslised. I guess what I want to say is that this is way too long discussion for an online forum. Get a JAVA TREADS by O'Reilly to get all the details...
regards,
VG.
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sarim,
The question reads What can cause ...; since some system's do use time slicing answer 2 is valid.
If the question said What always causes... or What must cause... then you would be right and answer 2 would not apply.
Hope that helps.
------------------
Jane
The cure for boredom is curiosity.
There is no cure for curiosity.
-- Dorothy Parker
 
Poop goes in a willow feeder. Wipe with this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic