• 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 priority

 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have read in K&B book that once a thread get their priority it cannot be changed.
So what about that:

What priority does the thread have?
My guess: 10 (according to K&B book)
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have read in K&B book that once a thread get their priority it cannot be changed.



A thread priority can be changed with the setPriority() method.

Henry
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
*phew* I'd just written some code to test the "setPriority" behaviour and was worried about my understanding when I say the priority changing.

I guess K&B mean the JVM will not, for its own reasons, change the priority of a thread; they way it might, for its own reasons, yank a thread back to the Runnable pool or ignore "yield()".
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tangentially related -and possibly outdated, applying to older JVM versions- I recall it being best practice not to change the priority of threads, because unpredictable and undesirable behavior might result. Sorry, I can't recall the details.
 
reply
    Bookmark Topic Watch Topic
  • New Topic