2008年04月24日

C#中简单实现多线程

C#中简单实现多线程,

using System;
using System.Threading;

namespace ConsoleApplication1
{
 /// <summary>
 /// Class1 的摘要说明。
 /// </summary>
 class Class1
 {
  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main(string[] args)
  {
   //
   // TODO: 在此处添加代码以启动应用程序
   //
   Thread thread1 = new Thread(new ThreadStart(Method1));
   Thread thread2 = new Thread(new ThreadStart(Method2));
   thread1.Start();
   thread2.Start();
  
  }
  public static void Method1()
  {
   while(true)
   {
    Console.WriteLine("this is thread : 1");
    Thread.Sleep(1000);

   }
  
  }
  public static void Method2()
  {
   while (true)
   {
    Console.WriteLine("this is thread : 2");
    Thread.Sleep(1520);
   }
  

  }
 }
}

本文转自:SEO基地

本文链接:http://www.11zhuce.com/seo/457.html

2008年12月13日--张靓颖上海演唱会

0 回复,0 引用: C#中简单实现多线程

添加回复

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。