Maximum number of threads in a .NET app?

前端 未结 7 2063
小蘑菇
小蘑菇 2020-11-22 17:43

What is the maximum number of threads you can create in a C# application? And what happens when you reach this limit? Is an exception of some kind thrown?

7条回答
  •  借酒劲吻你
    2020-11-22 17:54

    Jeff Richter in CLR via C#:

    "With version 2.0 of the CLR, the maximum number of worker threads default to 25 per CPU in the machine and the maximum number of I/O threads defaults to 1000. A limit of 1000 is effectively no limit at all."

    Note this is based on .NET 2.0. This may have changed in .NET 3.5.

    [Edit] As @Mitch pointed out, this is specific to the CLR ThreadPool. If you're creating threads directly see the @Mitch and others comments.

提交回复
热议问题