Retrieves the maximum number of concurrent threads that the ThreadPool can create.
| Name | Description |
|---|---|
workerThreads |
When this method returns, contains the maximum number of concurrent system threads that can be created to execute theThreadPool's methods. |
completionPortThreads |
When this method returns, contains the maximum number of concurrent I/O threads that can be created to execute the ThreadPool's methods. |
The ThreadPool manages a pool of worker threads and a pool of I/O completion threads. You can use this method to query the maximum number of threads in each pool. The actual number of threads in the pool can vary based on system load and the values set by ThreadPool.SetMaxThreads.
The number of worker threads determines how many CPU-bound operations can run concurrently. The number of I/O completion threads determines how many asynchronous I/O operations can be outstanding concurrently.
using System;
using System.Threading;
public class Example
{
public static void Main()
{
int workerThreads;
int completionPortThreads;
// Get the maximum number of threads
ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads);
Console.WriteLine("ThreadPool Max Threads:");
Console.WriteLine(" Worker threads: {0}", workerThreads);
Console.WriteLine(" Completion port threads: {0}", completionPortThreads);
}
}