Does Task.Wait release the calling thread if that thread is from the thread pool?

StackOverflow https://stackoverflow.com/questions/23652802

  •  22-07-2023
  •  | 
  •  

سؤال

If I call task.wait() inside a thread that is managed by the thread pool, is that thread handed back to the thread pool so that it can be reused elsewhere while waiting or is it kept idle (therefore not reused) until the task completes ?

I would suspect the second one as it would be the behaviour for any thread that is not managed by the thread pool.

هل كانت مفيدة؟

المحلول

Simple answer: No. The thread has no concept of a thread pool, so Wait can not do special things. Also reusing a thread like this may have serious side effects (on thread local variables which may have changed).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top