• 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

Threads

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
Can someone tell me if there are 2 threads at "Ready state" , one is at higher priority and one at lower priority , then which one will the JVM start for sure ?
I want to answer "higher priority thread" but want to be sure because when it comes to "Threads" many times the answer is the "unpredictable" .I want to know from exam point of view.
The other likely answer is "We can be sure that number of times a higher priority thread runs is higher than number of times a lower priority thread runs but we cannot say for sure that higher prioriy thread will always start first "
Can someone please explain thread priorities w.r.t SCJP 1.4 ?
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer to the above question depends on the implemention of the algorithm by either JVM or under lying OS. As we can't assume about either of them , unfortunately the answer for this question is uncertinity. If at all these ype of questions appear then definitely one of the given options would be some thing like unpredictable.
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the exam point of view. You cannot rely on thread priorities for program correctness. Your Java program could be running ok in some OS, but not in others. Because some OS (tipically Unixes) allow the programmer to determine which thread is running based on their priorities. While in others (tipically Windows) there is not guarantee which thread is running at a given time; due to for instance boosting of low-priority IO Threads, or to avoid starvation of a low-priority thread.
This is the reason why you will not be asked for the kinds of questions you made in the exam.
[ January 20, 2003: Message edited by: Jose Botella ]
 
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic