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
版权声明:本文为博主原创文章,转载请附上博文链接!


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM