public CustomThreadPool(string name, int threadPoolSize = DefaultThreadPoolSize, ThreadPriority priority = ThreadPriority.Normal)
{
if (threadPoolSize == DefaultThreadPoolSize)
{
int n;
ThreadPool.GetMaxThreads(out _threadPoolSize, out n);
}
else
{
Debug.Assert(threadPoolSize > 0);
_threadPoolSize = threadPoolSize;
}
_threads = new List<CustomThreadPoolThread>();
_semaphore = new Semaphore(_threadPoolSize, _threadPoolSize);
Priority = priority;
Name = name;
}