Thread priorities specify the relative priority of one thread versus another.
Thread priorities specify the relative priority of one thread versus another.
Threads are scheduled for execution based on their priority. The scheduling algorithm used to determine the order of thread execution varies with each operating system.
All threads with the same priority are treated as equal - the scheduler assigns time slices in a round-robin fashion to all threads with the highest priority. If none of these threads are ready to run, the scheduler assigns time slices in a round-robin fashion to all threads with the next highest priority.
A round robin scheduler runs through equal priority threads in the order they are stored in memory. This helps prevents deadlock if multiple threads have the same priority, although thread safety and performance can be compromised.