Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question : dotnet counters ThreadPool Thread Count and ThreadPool.SetMinThread #110304

Closed
mamdos opened this issue Dec 2, 2024 · 4 comments
Closed
Labels
area-System.Threading question Answer questions and provide assistance, not an issue with source code or documentation.

Comments

@mamdos
Copy link

mamdos commented Dec 2, 2024

I moved this issue from microsoft/dotnet to this repo.

Hello
I set ThreadPool.SetMinThread to 200 but ThreadPool Thread Count in dotnet counters shows less than 200.
Does ThreadPool Thread Count show just in use thread?
please explain.

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Dec 2, 2024
@mamdos
Copy link
Author

mamdos commented Dec 2, 2024

issue link : microsoft/dotnet#1460

Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@stephentoub
Copy link
Member

ThreadPool.SetMinThreads doesn't force that number of threads into existence if there's not enough work available for them to do. Rather, it sets the min threshold up to which point the pool will ensure there are threads available if there's work available. For example, let's say you set the min to 10. You queue a work item, there are currently zero threads available to process that work item, so the pool will immediately inject a thread. Now you queue another 9 work items. There are no threads available to process those work items (the previous one is still busy with the previous work item), so the pool will immediately inject another 9 threads to handle those work items. Now you queue 2 more work items. You've reached the minimum you set of 10 threads, so the pool will no longer immediately inject additional threads and will instead prefer to wait for one of the existing threads to finish processing the previously queued work items so that it may handle one of the newly queued ones.

@stephentoub stephentoub added question Answer questions and provide assistance, not an issue with source code or documentation. and removed untriaged New issue has not been triaged by the area owner labels Dec 2, 2024
@stephentoub stephentoub closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2024
@mamdos
Copy link
Author

mamdos commented Dec 2, 2024

Thank you for the response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Threading question Answer questions and provide assistance, not an issue with source code or documentation.
Projects
None yet
Development

No branches or pull requests

2 participants