Thread Pool vs Thread Spawning

前端 未结 12 1636
梦如初夏
梦如初夏 2020-12-08 00:27

Can someone list some comparison points between Thread Spawning vs Thread Pooling, which one is better? Please consider the .NET framework as a reference implementation tha

12条回答
  •  太阳男子
    2020-12-08 01:19

    All depends on your scenario. Creating new threads is resource intensive and an expensive operation. Most very short asynchronous operations (less than a few seconds max) could make use of the thread pool.

    For longer running operations that you want to run in the background, you'd typically create (spawn) your own thread. (Ab)using a platform/runtime built-in threadpool for long running operations could lead to nasty forms of deadlocks etc.

提交回复
热议问题