Where and how to check through code number of threads available in threadpool.
What i want is: For example if no of threads in threadpool are 10 then at any given time I should not be using say more than 3 threads. Once an existing thread gets free, I should start a new task, keeping max count 3.
ThreadPool will create maximum of 10 threads to process 10 requests at a time. After process completion of any single Thread, ThreadPool will internally allocate the 11th request to this Thread and will keep on doing the same to all the remaining requests.
A thread pool is - as the name suggests - a pool of worker threads which are always running. Those threads then normally take tasks from a list, execute them, then try to take the next task. If there's no task, the thread will wait.
NET Thread Pool default numbers of threads: 1023 in Framework 4.0 (32-bit environment) 32767 in Framework 4.0 (64-bit environment)
ThreadPool.GetAvailableThreads will give you number of available threads. ThreadPool.GetMaxThreads will give you max number of threads. The difference will give you the number of active threads.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With