• 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 priority (examulator.com)

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got this question on examulator

Which of the following statements are true?
Select 1 option

1) A higher priority Thread will prevent a lower priorty Thread from getting any access to the CPU.
2) The yield method only allows any higher priority priority thread to execute.
3) The Thread class has a static method called yield
4) Calling yield with an integer parameter causes it to yield for a specific time.


The correct answer was 3.
I think 1 and 3 should be the correct answer
This is a quote from Kathy & Berts book


The closest thing to a guarantee is that at any given time, when a thread is running it will usually not have a lower priority than any thread in the runnable state. If a low-priority thread is running when a high-priority thread enters runnable, the JVM will preempt the running low-priority thread and put the high-priority thread in.


Could someone please tell me if 1 is the correct answer also.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My problem with 1 is that it is worded as an absolute. Exactly what happens is up to the JVM thread management and what the higher priority Thread is trying to do.
Note the "usually" in the quoted passage.
Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic