开发者

foreground threads vs background threads

开发者 https://www.devze.com 2023-03-03 05:43 出处:网络
MSDN states that: Background threads are开发者_如何转开发 identical to foreground threads with one exception: a background thread does not keep the managed execution environment running

MSDN states that:

Background threads are开发者_如何转开发 identical to foreground threads with one exception: a background thread does not keep the managed execution environment running

  1. Is there any dereference in the Thread Quantum that given by OS to the thread if it were a background thread rather than the foreground threads? Check this.

  2. When setting a background thread priority to a higher value like Highest, will it get more quantum than a foreground one with lower priority?

Thanks in advance.


Managed foreground/background threads, the Windows thread quantum and thread priority are orthogonal concepts.

  • Being a foreground thread means that the process cannot be stopped until it (and all other foreground threads) are stopped.
  • The quantum is the length of time a thread gets to run before the system will consider scheduling another thread on that processor.
  • The thread priority determines the pecking order within all ready to run, waiting threads.

Of these three items, only foreground/background pertains to managed code.

Now to your questions.

  1. The foreground process is a Windows concept. It is unrelated to foreground/background threads in .net.
  2. Thread priority does not affect the quantum.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号