using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace ThreadTest
{
class Program
{
static void Main(string[] args)
{
Thread.CurrentThread.Name = "主线程";
Thread f = new Thread(new ThreadStart(Work));
f.Start();
int i = 0;
while (i < 50)
{
Console.WriteLine(Thread.CurrentThread.Name+"t"+i.ToString());
i++;
}
}
static void Work()
{
Thread.CurrentThread.Name = "子线程";
int i = 0;
while (i < 50)
{
Console.WriteLine(Thread.CurrentThread.Name+"t"+i.ToString());
i++;
}
}
}
}[@more@]
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace ThreadTest
{
class Program
{
static void Main(string[] args)
{
Thread.CurrentThread.Name = "主线程";
Thread f = new Thread(new ThreadStart(Work));
f.Start();
int i = 0;
while (i < 50)
{
Console.WriteLine(Thread.CurrentThread.Name+"t"+i.ToString());
i++;
}
}
static void Work()
{
Thread.CurrentThread.Name = "子线程";
int i = 0;
while (i < 50)
{
Console.WriteLine(Thread.CurrentThread.Name+"t"+i.ToString());
i++;
}
}
}
}[@more@]
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10395457/viewspace-980399/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10395457/viewspace-980399/