简体   繁体   中英

Number of available threads in threadpool

In a Threadpool, I have set maximum number of threads.I want number of worker threads are available. i tried.

     ThreadPool.GetAvailableThreads(out x, out y);

Using this, I got number of available threads (x) which was only decreasing.There was no increase in a number of available threads (x) even after their task was done. How to get actual number of available threads in thread pool.

The GetAvailableThreads() method does not tell you how many threads there are, it returns how many extra threads still can be created.

From MSDN:

When GetAvailableThreads returns, the variable specified by workerThreads contains the number of additional worker threads that can be started,

And concerning

here was no increase in a number of available threads (x) even after their task was done.

How long did you wait? The pool will only slowly destroy idle threads.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM