zoukankan      html  css  js  c++  java
  • System.Threading.Thread的使用及传递参数等总结

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

    namespace ConsoleApplication3
    {
    class Program
    {
    static void Main(string[] args)
    {
    //线程启动One()
    Thread t = new Thread(() => One());
    t.Start();

    //线程启动One(object p) 方法一(传递参数)
    Thread tt = new Thread(() => One("mang"));
    tt.Start();

    //线程启动Two(object p) 方法二(传递参数)
    Thread ttt = new Thread(new ParameterizedThreadStart(Two));
    ttt.Start("mangmang");
    Console.ReadLine();

    //构造函数
    //new Thread(ThreadStart start) 初始化Thread类的新实例
    //start 类型:System.Threading.ThreadStart
    // ThreadStart委托,它表示此线程开始执行时要调用的方法。
    }

    static void One()
    {
    Console.WriteLine("One");
    }

    static void One(object p)
    {
    Console.WriteLine("One's parameter is " + p.ToString());
    }

    static void Two(object p)
    {
    Console.WriteLine("Two's parameter is " + p.ToString());
    }
    }
    }

  • 相关阅读:
    关于页面跳转
    javascript之继承
    ubuntu+mysql+php+apache2+wordpress建站全记录
    Vue双向绑定原理解析
    Excel导入
    Excel文件下载(导出)
    IDEA创建Activiti工作流(集成的方式,生成表)
    git基本操作
    git中分支操作
    整合dubbo的依赖
  • 原文地址:https://www.cnblogs.com/asdyzh/p/9869948.html
Copyright © 2011-2022 走看看