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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.