zoukankan      html  css  js  c++  java
  • C# 多线程传递参数或多个参数


    using System;
    using System.IO;
    using System.Text;
    using System.Threading;

    namespace ConsoleApp7
    {
    class Program
    {
    static void Main(string[] args)
    {
    for (int i = 0; i < 10; i++)
    {
    MyThread myThread = new MyThread();
    myThread.id = i + 1;
    myThread.name = "张三" + i;
    myThread.money = 1000 + i;
    Thread thread = new Thread(myThread.ThreadMain);
    thread.Start();
    }
    Console.ReadLine();
    }

    public class MyThread
    {
    public int id { set; get; }
    public int money { set; get; }
    public string name { set; get; }

    public void ThreadMain()
    {
    int threadId = Thread.CurrentThread.ManagedThreadId;
    Console.WriteLine("线程ID {0} {1} {2} {3}", threadId, id, money, name);
    }
    }
    }
    }
    ---------------------
    作者:smartsmile2012
    来源:CSDN
    原文:https://blog.csdn.net/smartsmile2012/article/details/82796066
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    PHP小技巧
    PHP Ajax跨域解决
    单点登录
    Linux 常用命令
    php面向对象--继承
    vueDemo
    vueSource
    vuex
    Vue.js
    关于前后端分离
  • 原文地址:https://www.cnblogs.com/shuaiheng/p/10734038.html
Copyright © 2011-2022 走看看