Thread Priorities

Not all threads are created equal. Well, that's not really true, all threads are created equal. You just make them unequal later by updating the Priority property of the Thread class. With the .NET Framework, you have five levels of priorities available to place on a thread:

  • Highest

  • AboveNormal

  • Normal

  • BelowNormal

  • Lowest

You can find each of the preceding priorities in the System::Threading:ThreadPriority enumeration.

The basic idea behind priorities is that all threads are created at a Normal priority. When unaltered, each "running" thread gets an equal share of processor time. If, on the other hand, you change the priority of the thread to a higher level—AboveNormal, for example—then the documentation says it will be scheduled to execute prior to threads at a lower level. Well, this is sort of the case. If that were truly how the Framework did it, then lower level threads would never run (in other words, they would starve) until the higher level thread finished. This doesn't happen, so it appears that the .NET Framework has additional logic in it to allow lower level priority threads to have at least a little processor time.

Normally you don't want to mess with priorities, but for those rare occasions, the functionality, as you have come to expect with the .NET Framework, is provided.

Managed C++ and. NET Development
Managed C++ and .NET Development: Visual Studio .NET 2003 Edition
ISBN: 1590590333
EAN: 2147483647
Year: 2005
Pages: 169 © 2008-2017.
If you may any questions please contact us: