Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do you change the priority range for threads?

 
Wanki Ho
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Say I want a thread priority range between 0-127 with a lower number meaning a higher priority. How would I simulate that?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a word, you can't. The fact is the Thread priority constants are implementation dependent, so a priority of 1, 2, and 3 may be identical on Windows and distint on Solaris.
You could try to come up with an algorithm that would have each thread yield and sleep based on your arbitrary numbering but the behavior would not be consistent in all probability. The big problem with threads is you are at the mercy of the OS that creates and schedules the threads.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Threads and Synchronization forum...
 
permaculture is largely about replacing oil with people. And one tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!