从智能线程池中删除空闲线程的正确方法

从智能线程池中删除空闲线程的正确方法

本文介绍了从智能线程池中删除空闲线程的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我一直在使用C#智能线程池做一些工作,但发现当前的智能线程池释放没有任何关于删除的空闲线程。这可能会也可能不会导致智能线程池内存泄漏。



smartthreadpool.ProcessQueueItem()方法中当空闲线程超时时,方法会多次调用 InforComleted()方法。但是 InformCompleted()只是从字典中删除了线程并且没有删除这些线程:

I have been using the C# smart thread pool to do some work but found the current smart thread pool release DOES NOT anything about the removed "idle threads". This may or may not cause smart thread pool memory leaks.

In the smartthreadpool.ProcessQueueItem() method there are several times the method calls InforComleted() method when a idle thread(s) is timed out. But the InformCompleted() just removes the thread from the dictionary and didn''t the delete these threads:

private void InformCompleted()
{
   if(_workerThreads.Contains(Thread.CurrentThread))
   {
      _workerThreads.Remove(Thread.CurrentThread);
   }
}



我想知道是否有人已经解决了这个问题并测试了它。



非常感谢。



祝你好运,

CodeBeetle123


I''m wondering if there is anyone out there already solved this problem and test it out.

Thank you very much.

Best regards,
CodeBeetle123

推荐答案


这篇关于从智能线程池中删除空闲线程的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 11:27