Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

threads priority

 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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)
 
Henry Wong
author
Marshal
Pie
Posts: 22119
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
 
Jason Irwin
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • 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()".
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic