zoukankan      html  css  js  c++  java
  • 线程的几种用法

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;

    namespace ConsoleApplication
    {
        class Program
        {
            static void Main(string[] args)
            {
                ////线程方法1
                //if (ThreadPool.QueueUserWorkItem(new WaitCallback(Program.WritePara), "这是传进去的参数"))
                //{
                //    Console.WriteLine("ok:");
                //    Console.Read();
                //}
                //线程方法2
                Thread th = new Thread(new ThreadStart(Write));
                th.Start();
                //线程方法3
                Thread thread = new Thread(new ParameterizedThreadStart(WritePara));
                thread.Start("Thread thread = new Thread( new ParameterizedThreadStart(WritePara))有参传递");


            }
            protected static void WritePara(object para)
            {
                Console.WriteLine("hello:" + para);
            }

            private static void Write()
            {
                Console.WriteLine(" Thread th = new Thread(new ThreadStart(Write));无参线程调用");
            }
        }
    }

  • 相关阅读:
    浏览器能正常访问的url,superagent不能正常访问
    Reactor模式理解
    牛客网剑指offer 二维数组的查找
    在C语言结构体中添加成员函数
    html页面字体相关
    html页面背景设定相关
    快速排序
    html页面边框的另一种写法
    2018暑期北航软件能力培养师资培训有感
    web.xml文件介绍
  • 原文地址:https://www.cnblogs.com/yexinw/p/3532530.html
Copyright © 2011-2022 走看看