tags:

views:

66

answers:

3

Hi all,

I have been reading about threadpools. A number of sites say that the default max threads on a threadpool is 25 (per processor). however i have not modified the max threads and when i do :

Threadpool.GetAvailableThreads(out WorkThreads, out compPortThreads);

I get 500,1000. I am running a dual core pc so wouldnt expect more than 50.

Do i actually have 500, 1000 in my pool ??

Thanks John

+4  A: 

The default number of threads per processor has changed significantly between different versions.

Trust the values obtained at runtime.

The current documentation states:

There is one thread pool per process. The thread pool has a default size of 250 worker threads per available processor, and 1000 I/O completion threads.

Jon Skeet
+1  A: 

That method returns the number of threads that CAN be started, not what is currently running. The information you read about 25 being the max is outdated. I'm not sure which version but the threadpool limits were bumped up significantly to avoid deadlock problems mostly due to developers not knowing what they were doing, IMHO.

Josh Einstein
+3  A: 

This has changed between versions:

From the documentation of the ThreadPool class in Visual Studio 2005:

There is one thread pool per process. The thread pool has a default size of 25 threads per available processor.

From the documentation of the ThreadPool class in Visual Studio 2010:

There is one thread pool per process. The thread pool has a default size of 250 worker threads per available processor, and 1000 I/O completion threads.

As a funny side note: For Visual Studio 2008, the English documentation promises 250 worker threads, whereas the German translation only gives you 25. Ah, the joys of buggy translations...

Heinzi