当前位置:首页>网络学院>程序开发>c#教程>文章内容

ThreadPoolHelper线程池源代码

[ 来源:http://www.it55.com | 作者: | 时间:2007-12-24 | 收藏 | 推荐 ] 【


   delegate { Console.WriteLine("b"); },
   delegate { Console.WriteLine("c"); }
   );
  
   Console.WriteLine("Main thread does some work, then sleeps.");
   // If you comment out the Sleep, the main thread exits before
   // the thread pool task runs. The thread pool uses background
   // threads, which do not keep the application running. (This
   // is a simple example of a race condition.)
   Thread.Sleep(1000);
  
   Console.WriteLine("Main thread exits.");
   }
  
   // This thread procedure performs the task.
   static void ThreadProc()
   {
   // No state object was passed to QueueUserWorkItem, so
   // stateInfo is null.
   Console.WriteLine("Hello from the thread pool.()");
   }
  
   // This thread procedure performs the task.
   static void ThreadProc(object stateInfo)
   {
   // No state object was passed to QueueUserWorkItem, so
   // stateInfo is null.
   Console.WriteLine("Hello from the thread pool.(object stateInfo)");
   }
   }
  }  

(编辑:IT资讯之家 www.it55.com

返回顶部
共3页: 上一页 [1] [2] 3 下一页  

网友评论

[以下评论为网友观点,不代表本站。请自觉遵守互联网相关政策法规,所有连带责任均有评论者自负。]
[不超过250字]