Advantage of using Thread.Start vs QueueUserWorkItem

后端 未结 9 1609
有刺的猬
有刺的猬 2020-11-28 12:49

In multithreaded .NET programming, what are the decision criteria for using ThreadPool.QueueUserWorkItem versus starting my own thread via new Thread() and Thread.Start()?

9条回答
  •  遥遥无期
    2020-11-28 13:19

    The thread pool is always available in .NET apps, regardless of what kind.

    The cost for starting a thread from the thread pool via ThreadPool.QueueUserWorkItem will be no more than the cost of starting your own thread, and could be less.

    If you just want a few threads for a short period, then use the thread pool. That's what it's for.

提交回复
热议问题