C#简单线程演示代码
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace ThreadDemo
{
class Program
{
static void Main(string[] args)
{
Thread thread1 = new Thread(new ThreadStart(method1));
Thread thread2 = new Thread(new ThreadStart(method2));
thread1.Start();
thread2.Start();
}
public static void method1()
{
for (int i=0;i<100;++i)
{
Console.WriteLine("a");
}
}
public static void method2()
{
for (int i=0;i<100;++i)
{
Console.WriteLine("b");
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace ThreadDemo
{
class Program
{
static void Main(string[] args)
{
Thread thread1 = new Thread(new ThreadStart(method1));
Thread thread2 = new Thread(new ThreadStart(method2));
thread1.Start();
thread2.Start();
}
public static void method1()
{
for (int i=0;i<100;++i)
{
Console.WriteLine("a");
}
}
public static void method2()
{
for (int i=0;i<100;++i)
{
Console.WriteLine("b");
}
}
}
}