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

推荐订阅源

Forbes - Security
Forbes - Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
F
Fortinet All Blogs
B
Blog
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
Y
Y Combinator Blog
Microsoft Azure Blog
Microsoft Azure Blog
L
LangChain Blog
Recent Announcements
Recent Announcements
U
Unit 42
Martin Fowler
Martin Fowler
M
MIT News - Artificial intelligence
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Register - Security
The Register - Security
Recorded Future
Recorded Future
C
Check Point Blog
V
V2EX
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
F
Full Disclosure
小众软件
小众软件
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
MongoDB | Blog
MongoDB | Blog
爱范儿
爱范儿
P
Proofpoint News Feed
罗磊的独立博客
量子位
D
Docker
博客园_首页
D
DataBreaches.Net
Project Zero
Project Zero
博客园 - 司徒正美
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - Franky
Security Latest
Security Latest
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
Netflix TechBlog - Medium
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
大猫的无限游戏
大猫的无限游戏

博客园 - edobnet

phonegap 开发初探 .net C# ADC接口中DES加密算法 阿里软件接口开发基础(淘宝网) C# SQL 2005自动备份文件删除 短信猫与中国移动CMPP2。0收发短信实例 通过OSQL命令执行SQL SERVER批SQL 针对sql 2005优化的高性能分页存储过程 .net framework 2.0以上修改config配制更容易 - edobnet LinQ操作汇总(From CSharpSamples) 远程注册表读取,与多线程池的应用. 使用JAVASCRIPT控制,IFAME的内容,从而使用投票点击等功能 ADSL自动断拨号类 类拟EXCEL表格锁定的功能的实现! - edobnet - 博客园 sql Server 2000 分区视图的运用 利用.Net 线程池提高应用程序性能. google 中国编程大赛测试题,及自己的解答 触发器在增量同步数据的运用. 进程服务编写,与启动停止控制 js异步XMLhttpPost,并带有,等待显示,防正,XMLhttpPost请求时间过来,而使浏览器死掉! - edobnet - 博客园
线程,线程数控制!
edobnet · 2005-12-26 · via 博客园 - edobnet

多线程与线程池的介绍看这里
http://edobnet.cnblogs.com/archive/2005/11/29/287094.html

        //private int threadNum = 0;
        
//private AutoResetEvent myResetEvent = new AutoResetEvent(false);
        /// <summary>
        
/// 线程记数器
        
/// </summary>

        private int number = 0;

        
/// <summary>
        
/// 线程池执行
        
/// </summary>

        public void Execute()
        
{
            
int maxCount = int.Parse(ConfigurationSettings.AppSettings["Count"]);
            
int time = int.Parse(ConfigurationSettings.AppSettings["Time"]);
            
foreach (TG_EvaluteBaseDatasSet service in this)
            
{
                
                
                
//                System.Threading.ThreadStart ts = new System.Threading.ThreadStart(service.GetXMLResult);
                
//                System.Threading.Thread th = new System.Threading.Thread(ts);
                
//                th.Start();
                WaitCallback async = new WaitCallback(FExeute);

                
while(true)
                
{
                    
                    Monitor.Enter(number);
                    
if(number>maxCount)
                        Thread.Sleep(time);
                    
else
                        
break;
                    Monitor.Exit(number);
                }

                
if(ThreadPool.QueueUserWorkItem(async,service))
                    Interlocked.Increment(
ref number);
            }

            
while(true)
            
{
                
//myResetEvent.Set();
                Monitor.Enter(number);
                
if( number <= 0)
                    
break;
                
else
                    Thread.Sleep(time);
                Monitor.Exit(number);
            }

            OnTgFinishReport(
new EventArgs());

        }

        
/// <summary>
        
/// 线程执行一个计算
        
/// </summary>
        
/// <param name="Param">执行对象<see cref="GleNet.HG.HTResolver.TG_EvaluteBaseDatasSet">TG_EvaluteBaseDatasSet</see></param>

        public  void FExeute(object Param)
        
{
            
//myResetEvent.WaitOne();
            using(TG_EvaluteBaseDatasSet service = (TG_EvaluteBaseDatasSet)Param)
            
{
                service.doResult();
                writeFile(Path,service)    ;
                OnTgReport(
new ReportEvent(service.TE_PASS_RANGE,service.TE_YEAR,service.TE_MONTH,int.Parse(service.TE_I_E_FLAG),int.Parse(service.TE_ENTRY_TYPE),number));
            }

            Interlocked.Decrement(
ref number);
            Console.WriteLine(
"LEFT:"+number);
            
        }

由程序控制线程数量,并且, 由MONITOR进行保护!