Java Thread Priorities
Hello, Could anyone direct me to some official documentation that explains how Java Thread are prioritized. Also, could you go ahead and give me a brief description on how they are by default prioritized. For example, if I create two different threads doing two totally different things, will one of them by default have a higher priority or will they have equal priority?
A project I am working on requires these two threads I've created to have an equal time-slice so to speak. I don't want one thread getting more attention than the other, regardless of what code is running in the threads.
Thanks for your help!
I've written a couple of articles on this topic that may be of interest. I wouldn't say they constitute "official documentation", but they're based on a fairly close reading of the JVM source code (Hotspot) and some reasonably authoritative works on how thread scheduling works in Windows and Linux:
Correct me if I'm wrong, but after reading your first link it sounds like I'm not going to see much of a difference between which Thread gets executed more? I'm gathering this notion based on the analysis of the threads generating random numbers and 1-8 priorities practically generate the same amount while 9-10 generate significantly more (not much of a difference between 9-10 though).
If this is the case and I keep in mind that Threads and Priorities can change based on OS and VM, I should be relatively safe in making the assumption that if I create two threads using the Default priority (or just not setting a priority) they'll likely get the same run time?
I should also mention that I do not intend to deal with IO with these threads. They'll simply be changing global variables and such.
P.S. Great articles