开发者

Thread vs ThreadPool - .Net 2.0

I'm not able to understand the difference between Thread vs ThreadPool. Consider i've to manipulate 50,000 records using threads.

In case of threads i need to either predefine no of threads or no of records per threads. Either of them has to be constant.

In case of threadpool we dont need to set any of them theoretically. But practically we need to assign the number of records per thread, because the no of threads may grow extremely large if the input no of records is huge.

Any insight开发者_Go百科s on this?


Here is a complete treatment on Threads and ThreadPools that will answer your question. includes when to use one vs the other.

http://www.yoda.arachsys.com/csharp/threads/


There is a huge cost in creating and destroying threads. A thread pool takes away this problem by maintaining open threads for you. When a thread in a pool is done with its work, the thread is returned to the pool instead of being destroyed. Then when you have to do more work, the already open thread is taken from the pool. This is much more efficient.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜