Thread vs ThreadPool

后端 未结 11 2337
鱼传尺愫
鱼传尺愫 2020-11-22 15:57

What is the difference between using a new thread and using a thread from the thread pool? What performance benefits are there and why should I consider using a thread from

11条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 16:33

    Thread:

    1. Creating a Thread is far slower than using Thread-pool.
    2. You can change the priority of a thread.
    3. The max number of threads in a process related to resources.
    4. Thread is at the OS level and controlled by OS.
    5. Using Thread is a better option when the task is relatively long-running

    Thread-Pool:

    1. Running a Thread on thread-pool is far faster than directly creating a Thread.
    2. You can not change the priority of a thread run based on Thread-pool.
    3. There is only one Thread-pool per process.
    4. The Thread-pool is managed by CLR.
    5. The Thread-pool is useful for short-lived operation.
    6. The numbers of Threads in Thread-pool is related to the application load.
    7. TPL tasks run based on Thread-pool

提交回复
热议问题