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);
}
}
}
}
C# 多线程传递参数或多个参数
本文转载:CSDN博客