zoukankan      html  css  js  c++  java
  • C#使用线程池创建线程

    using System;
    using System.Threading;
    
    public class Example 
    {
        public static void Main() 
        {
            // Queue the task.
            ThreadPool.QueueUserWorkItem(ThreadProc);
            Console.WriteLine("Main thread does some work, then sleeps.");
            Thread.Sleep(1000);
    
            Console.WriteLine("Main thread exits.");
        }
    
        // 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.");
        }
    }
    // The example displays output like the following:
    //       Main thread does some work, then sleeps.
    //       Hello from the thread pool.
    //       Main thread exits.
  • 相关阅读:
    装饰器和迭代器
    闭包函数
    函数对象
    Python函数
    函数的基本使用
    文件处理
    量化策略
    Android--生命周期
    算法转AI平台工程师记录-0
    python3.6安装
  • 原文地址:https://www.cnblogs.com/bincoding/p/7448674.html
Copyright © 2011-2022 走看看