Thread2(C#)

nonamedemo發表於2007-11-01
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@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10395457/viewspace-980399/,如需轉載,請註明出處,否則將追究法律責任。