ThreadPool in .NET Framework v2.0 Service Pack 1

Wed, November 28, 2007, 02:42 AM under dotNET
I was in Joe's session at Tech Ed when he mentioned in passing (almost as a throwaway comment) that there are some changes in the System.Threading.ThreadPool in v3.5. I guessed that what he really meant was changes in v2.0 Service Pack 1 for the ThreadPool class (which I confirmed myself by testing it on my machine). It goes to show you that you cannot rely on API surfacing to discover all the changes in SP1 and somebody should come up with a master list... Anyway, you are probably more interested in what the change is, right?

Apparently, the ThreadPool now defaults to having a max of 250 threads instead of 25. I found this ironic because I recall that the NETCF ThreadPool had 256 in v1.0 and changed to 25 to match the desktop behaviour in v2.0 and I wondered if they caught this change in NETCF v3.5 so they can be in sync again. Seems not :-)

Regardless, remember that starting with v2.0 you can change the max yourself not just through hosting APIs but through the managed SetMaxThreads method. In fact, to validate all of the above, I used the counterpart method, GetMaxThreads that you can try yourself:
  int a, b;
ThreadPool.GetMaxThreads(out a, out b);
MessageBox.Show(a.ToString());
:-)
Comments are closed.