• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Priority not working properly

 
Kashinath Roy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 287
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21518
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

Henry
 
Nomaan Butt
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic