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

推荐订阅源

T
Tor Project blog
B
Blog RSS Feed
M
MIT News - Artificial intelligence
WordPress大学
WordPress大学
H
Hackread – Cybersecurity News, Data Breaches, AI and More
罗磊的独立博客
GbyAI
GbyAI
N
Netflix TechBlog - Medium
博客园 - 司徒正美
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
宝玉的分享
宝玉的分享
W
WeLiveSecurity
Stack Overflow Blog
Stack Overflow Blog
Y
Y Combinator Blog
SecWiki News
SecWiki News
V
Vulnerabilities – Threatpost
Google DeepMind News
Google DeepMind News
C
CERT Recently Published Vulnerability Notes
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Register - Security
The Register - Security
Cisco Talos Blog
Cisco Talos Blog
Martin Fowler
Martin Fowler
A
About on SuperTechFans
S
Security @ Cisco Blogs
T
Tenable Blog
C
Check Point Blog
N
News and Events Feed by Topic
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Attack and Defense Labs
Attack and Defense Labs
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Cisco Blogs
P
Palo Alto Networks Blog
V
V2EX
博客园 - 聂微东
Project Zero
Project Zero
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Docker
N
News | PayPal Newsroom
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
小众软件
小众软件
Application and Cybersecurity Blog
Application and Cybersecurity Blog
人人都是产品经理
人人都是产品经理
V2EX - 技术
V2EX - 技术
I
Intezer
L
LINUX DO - 最新话题

博客园 - 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进行保护!