aspose file tools*
The moose likes Threads and Synchronization and the fly likes Thread.setPriority() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread.setPriority()" Watch "Thread.setPriority()" New topic
Author

Thread.setPriority()

Dennis Cook
Greenhorn

Joined: Jul 19, 2007
Posts: 1
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

Joined: Sep 11, 2006
Posts: 169
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
Marshal

Joined: Mar 22, 2005
Posts: 39577
    
  27
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.


Ping & DNS - updated with new look and Ping home screen widget
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
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.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

Google thread priority. There is a lot of info out there. It is much, much more complex then you imagine.


Ed's latest article: A Java Parallel Calamity http://coopsoft.com/ar/Calamity2Article.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread.setPriority()
 
Similar Threads
Looking for wrapper/installer for all platforms
Survey- What platform do you use to program in Java?
Writing a properties file with an applet
JSP & Servlets thru Online
How keep window on top but use other windows?