新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
C#線程類的定義實(shí)例解析
C#線程類的定義實(shí)例實(shí)現(xiàn)是如何的呢?我們使用Thread類,將Thread類封裝在一個(gè)MyThread類中,以使任何從MyThread繼承的類都具有多線程能力。MyThread類的代碼如下:

C#線程類的定義實(shí)例:
- //C#線程類的定義實(shí)例
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- namespace MyThread
- {
- abstract class MyThread
- {
- Thread thread = null;
- abstract public void run();
- public void start()
- {
- if (thread == null)
- thread = new Thread(run);
- thread.Start();
- }
- }
- }
C#線程類的定義之使用MyThread類:
- class NewThread : MyThread
- {
- override public void run()
- {
- Console.WriteLine("使用MyThread建立并運(yùn)行線程");
- }
- }
- static void Main(string[] args)
- {
- NewThread nt = new NewThread();
- nt.start();
- }
C#線程類的定義實(shí)例基本的內(nèi)容就向你介紹到這里,希望對(duì)你了解和學(xué)習(xí)C#線程類的定義有所幫助。
網(wǎng)頁(yè)題目:C#線程類的定義實(shí)例解析
URL網(wǎng)址:http://www.5511xx.com/article/cogegid.html


咨詢
建站咨詢
