Thread2(C#)
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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【C#】Learn C# in X minutesC#
- [C#]C#中字串的操作C#字串
- [C#]C#時間日期操作C#
- C#C#
- C# 語言歷史版本特性(C# 1.0到C# 8.0彙總)C#
- C#語言歷史版本特性(C# 1.0到C# 8.0彙總)C#
- C# 9.0 正式釋出了(C# 9.0 on the record)C#
- C# ActivatorC#
- C# on DevCloudC#devCloud
- C# DbHeplerC#
- C# FirstOrDefaultC#
- C# 概念C#
- C#反射C#反射
- c# 方法C#
- c# ArraySegmentC#
- C# dynamicC#
- C# is與asC#
- Thrift c#C#
- C# HexEditC#
- c# abstractC#
- C# BackgroudWorkerC#
- XMLOperator[C#]XMLC#
- c# listviewC#View
- C#字串C#字串
- 《Effective C#》C#
- C# ViewStateC#View
- C#方法C#
- C#教程C#
- C# 物件C#物件
- C#特性C#
- c# channelC#
- C# 打包C#
- 重學c#系列——c#執行原理(二)C#
- C#神器"BlockingCollection"類實現C#神仙操作C#BloCGC
- C#入門之C#特點及HelloWorld程式C#
- C#基礎系列--C#中委託與事件(三)C#事件
- C#基礎系列--C#中委託與事件(一)C#事件
- 【C#開發】C#的協變和逆變C#