惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
P
Palo Alto Networks Blog
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
S
Schneier on Security
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
雷峰网
雷峰网
T
Tenable Blog
人人都是产品经理
人人都是产品经理
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
AWS News Blog
AWS News Blog
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
Scott Helme
Scott Helme
SecWiki News
SecWiki News
C
CERT Recently Published Vulnerability Notes
Recorded Future
Recorded Future
I
InfoQ
Security Archives - TechRepublic
Security Archives - TechRepublic
Help Net Security
Help Net Security
Cloudbric
Cloudbric
C
Check Point Blog
Engineering at Meta
Engineering at Meta
TaoSecurity Blog
TaoSecurity Blog
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
腾讯CDC
量子位
Application and Cybersecurity Blog
Application and Cybersecurity Blog
K
Kaspersky official blog
Vercel News
Vercel News
F
Full Disclosure
T
Troy Hunt's Blog
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs

博客园 - Easy Company

如何取得显示实现方法的MethodInfo SQL Server 2008中许多兼容性上的问题 Mock 对象何时使用? 目前不能使用SQL Server 2008 CTP February 2008存储Team Foundation Server 2008的数据 Javascript操作在各浏览器下的性能比较 WCF Web 编程模型资源 代码行数引起的思考 在按钮点击后禁用它直到操作完成 - Easy Company - 博客园 ASP.NET 2.0中使用强类型访问PreviousPage属性页的控件 Silverlight 与 Microsoft ASP.NET Futures (July 2007) 更新 VS 2008 和.NET 3.5 Beta 2 安装注意事项 Partial Methods CIL(Common Intermediate Language)指令集 刚刚下载了 Visual Studio 2005 Service Pack 1 (SP1) 使用 Facade 设计模式管理 ASP.Net Session 变量 .Net 中的日志 使用 Membership 时获取用户的最后登录时间 How To 推荐用于 AJAX 页面的进度指示器图片
ThreadPool 在.Net 2.0 SP1中的部分变化可能会让你的程序停止工作
Easy Company · 2008-05-24 · via 博客园 - Easy Company

最近Michael C. Kennedy在它的博客上写了一些关于.Net 2.0 SP1中ThreadPool的文章。

.NET 3.5 Brings Breaking Changes to ThreadPool中他介绍了一个对他影响很大的变化,新的.NET 2.0 SP1(随.NET 3.5 发布)忽略了ThreadPool.SetMinThreads导致他的程序停止运行。如果你的应用需要立即使用大量的线程池线程时,你必须通过ThreadPool.SetMinThreads提高最小线程数量,否则ThreadPool会尽快在线程池中分配最少数量的线程,接着每秒钟创建最多2个线程,直到达到最大线程数量的方法启动线程,它可能需要几秒钟才能完成。在文章中Michael给出了100个线程的测试示例,并在2008年2月26日提供了视频和相应的新的测试代码

另外Michael发现当太多线程等待其他任务结束时就会出现死锁,他通过向Vance Morrison(a .NET Runtime Performance Architect at Microsoft)确认那是一个Bug,他们将在.Net 2.0 SP2中修复。并且Vance给了Michael一个解决这个问题的策略,如下:

Take this "broken" code:

private static void UseThreadPool(int count)
        
{
            
for ( int i = 0; i < count; i++ )
            
{
                ThreadPool.QueueUserWorkItem(
                    
delegate { SlowMethod(); } );
            }

        }

And add a strategic Thread.Sleep and it's fixed:

        private static void UseThreadPool(int count)
        
{
            
for ( int i = 0; i < count; i++ )
            
{
                ThreadPool.QueueUserWorkItem(
                    
delegate { SlowMethod(); } );
                Thread.Sleep(
1);
            }

        }