Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread.setPriority()

 
Dennis Cook
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been experimenting with thread priorities in the various versions of Java for the Windows, Mac and Linux platforms. It seems that Windows and Mac will honor the priority set on a thread, the Linux platform will not.

Has anyone experienced this problem, or have an explanation why it does not work?

Cookie
 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really don't know if the priority set on Threads are always honored...
There's always chances that it might not be honored also...
I have read this topic somewhere but could not remember..
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

I only have fuzzy knowledge on the topic myself, but I seem to recall that the recommended best practice was to avoid changing thread priorities, and leave it up to the JVM which thread to run.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
Welcome to JavaRanch.

I only have fuzzy knowledge on the topic myself, but I seem to recall that the recommended best practice was to avoid changing thread priorities, and leave it up to the JVM which thread to run.


But how does the JVM know which thread is more important? It doesn't. It would give equal precedence to my important calculation and some background clean-up task.

So priorities are a useful feature, I think. I certainly use them for background tasks. I admit that I have only actually checked whether they really run at reduced priority on Windows and maybe Mac OS X.

Unix/Linux certainly does have prioritisation, but does anyone know whether the Java threads can take advantage of it? The original poster is suggesting not.
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google thread priority. There is a lot of info out there. It is much, much more complex then you imagine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic