using System;
using System.Threading;
namespace C_Project
{
class Threading
{
public Threading() { }
public static void Main(string[] args)
{
Thread thread1 = new Thread(new ThreadStart(Threading.Method2));//定义线程1启动时调用的方法
Thread thread2 = new Thread(new ThreadStart(Threading.Method3));//定义线程2启动时调用的方法
Threading th = new Threading();
Thread thread3 = new Thread(new ThreadStart(th.Method1));//定义线程3启动时调用的方法
thread1.Start();//启动线程1
thread2.Start();//启动线程2
thread3.Start();//启动线程3
}
public void Method1()//非静态方法
{
while (true)
{
Console.WriteLine("this is thread :1");
Thread .Sleep(new TimeSpan (00,00,3));
}
}
public static void Method2()//静态方法
{
while(true)
{
Console.WriteLine("this is thread : 2");
Thread.Sleep(500);
}
}
public static void Method3()//静态方法
{
while (true)
{
Console.WriteLine("this is thread : 3");
Thread.Sleep(2000);
}
}
}
}