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

Thread Priority not working properly

Kashinath Roy

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



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

Joined: Sep 28, 2004
Posts: 20535

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


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:
subject: Thread Priority not working properly
It's not a secret anymore!