C#中怎么定义一个线程类

C#中怎么定义一个线程类

本篇文章为大家展示了C#中怎么定义一个线程类,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

C#线程类的定义实例:

//C#线程类的定义实例  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建立并运行线程");        }    }     static void Main(string[] args)    {         NewThread nt = new NewThread();        nt.start();    }

上述内容就是C#中怎么定义一个线程类,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注行业资讯频道。