Managing Multiple Threads with a Thread Pool

There are many real-world situations where the use of a thread makes sense but the thread's lifetime is short. For example, an architect might choose to spawn a thread to handle a short-lived socket connection to a remote party. Suppose the application has an average of 5 such connections occurring simultaneously, but each connection lasts an average of only 1 minute. In that case the application could easily spawn over 100 threads per hour, even though it really only needed 5 at a time.

This kind of behavior is wasteful and expensive and can be especially harmful on devices, with their limited resources. Particularly with devices, developers should always be stingy with resource allocation.

The .NET ...

Get Microsoft® .NET Compact Framework Kick Start now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.