using System;
using System.Threading;
namespace ConsoleApplication1
{
//class Program
//{
// static void Main(string[] args)
// {
// Thread DepthChangedThread = new Thread(delegate() { Console.WriteLine("OK"); });
// DepthChangedThread.Name = "OK";
// Console.WriteLine(DepthChangedThread.Priority.ToString());
// DepthChangedThread.Abort();
// DepthChangedThread.Join();
// DepthChangedThread.Start();
// }
//}
class MainRun
{
static int interval = 700;
static void Main()
{
Console.WriteLine("Interal to display results at?");
interval = int.Parse(Console.ReadLine());
Thread thisThread = Thread.CurrentThread;
thisThread.Name = "Main Thread";
//ThreadStart workerStart = new ThreadStart(StartMethod);
Thread workerThread = new Thread(delegate() { StartMethod(); });
workerThread.Name = "Worker";
workerThread.Start();
DisplayNumberThread();
Console.WriteLine("Main Thread Finished!");
Console.ReadLine();
}
static void DisplayNumberThread()
{
Thread thisThead = Thread.CurrentThread;
string name = thisThead.Name;
Console.WriteLine("Startint thread:"+name);
Console.WriteLine(name+":Current culture="+thisThead.CurrentCulture);
//int interval=700;
for (double i =1; i <=9*interval; i++)
{
if(i%interval==0)
Console.WriteLine(name+":count has reahed."+i);
}
}
static void StartMethod()
{
DisplayNumberThread();
Console.WriteLine("Worker Thread Finished!");
}
}
} //输入一个数后,显示出这个数的几个倍数。注意里面的ThreadStart 那,如果不用这个可以使用匿名委托。Culture是区域的意思。