MSDN does save live....

本文探讨了线程池的工作机制,指出线程并非按顺序执行而是随机调度,并揭示应用程序在所有线程完成前不会退出的误解。通过引用MSDN评论,强调线程池使用后台线程,不会阻止应用结束。

I am a huge fan of ms!

 

I wrote thread pool before, and unfortunely, it failed. At that time i was not willing to dig more and found out the truth until i read this article. http://www.cnblogs.com/artech/archive/2009/05/22/1486761.html%20Is that true?

It is important. Of threadpool, what i expected is as below:

1. The thread should be executed randomly, not from 1 to 10. It is true, it is true.

2. The application will not exit until all the threads are done. It is not true, it is not true...

And lucky enough, I read a comment from http://msdn.microsoft.com/en-us/library/4yd16hza.aspx, it mentioned that:

// If you comment out the Sleep, the main thread exits before the ThreadPool task has a chance to run.  ThreadPool uses  background threads, which do not keep the application running. 

 

转载于:https://www.cnblogs.com/pangpangxiong/archive/2009/07/01/1511658.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值