wood burning stoves*
The moose likes Threads and Synchronization and the fly likes Thread Priority not working properly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread Priority not working properly" Watch "Thread Priority not working properly" New topic
Author

Thread Priority not working properly

Kashinath Roy
Greenhorn

Joined: Apr 21, 2009
Posts: 9
But Why low is executing count more then High thread despite low priroty is low

Code:



Eclipsc IDE OUTPUT

Low-priority thread: 382730681
High-priori thread: 22847397


Harsha Smith
Ranch Hand

Joined: Jul 18, 2011
Posts: 287
Thread priorities don't often produce desired results. Although you can assign higher priority to the tasks you want to run before others, this may not work as you expect and also I think it depends on the OS
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18120
    
  39


Computers can do a lot in 10 seconds. Are you sure that the integers are not overflowing?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Nomaan Butt
Ranch Hand

Joined: Oct 19, 2011
Posts: 54
one can't be sure of the outcome when using threads, a lot depends on the OS and JVM. By the way in my system your program is giving expected results see below,

Low-priority thread: 1580488402
High-priori thread: 1658625472

try changing the priority values, which jvm you are using?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread Priority not working properly
 
Similar Threads
Joining Thread, Explanation required
Threads
When static variables get initialized?
Marcus Green's exam(q.no 22) Thread
producing javadoc