zoukankan      html  css  js  c++  java
  • [转贴]ParameterizedThreadStart,ThreadStart的使用,线程Thread传参数

     出自http://hi.baidu.com/ydalbj/blog/item/330b8d13f6959dd5f6039ec4.html

     

    Thread

    threadWithParam = new Thread(new ParameterizedThreadStart(new ThreadTest().ShowMsg));//threadWithParam.Start("this is a param.");

    threadWithParam.Start(

    thread.Start();

    "44444");Thread thread=new Thread(new ThreadStart(new Class11().ShowMsg));

    表示在 Thread 上执行的方法的委托方法,ThreadStart不能带参数,ParameterizedThreadStart是2.0中新增的,可以带参数(object类型的)

    using System.Threading;

    public void ShowMsg()
    {
        MessageBox.Show("Message Info.");
    }

    Thread thread = new Thread(new ThreadStart(ShowMsg));
    thread.Start();

    //带参数

    public void ShowMsg(object msg)
    {
        MessageBox.Show(msg.ToString());
    }

    Thread threadWithParam = new Thread(new ParameterizedThreadStart(new ThreadTest().ShowMsg));
    threadWithParam.Start("this is a param.");

    作者:菩提树下的杨过
    出处:http://yjmyzz.cnblogs.com
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    JQuery学习之语法
    sysbench
    fio——IO基准测试
    Python待分析的模块
    Taglist
    tcprstat
    SQL注入
    Nytro MegaRaid
    dstat
    Python之hashlib模块
  • 原文地址:https://www.cnblogs.com/yjmyzz/p/1259269.html
Copyright © 2011-2022 走看看