C#简单线程演示代码

代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace ThreadDemo
{
    
class Program
    {
        
static void Main(string[] args)
        {
            Thread thread1 
= new Thread(new ThreadStart(method1));
            Thread thread2 
= new Thread(new ThreadStart(method2));
            thread1.Start();
            thread2.Start();
        }

        
public static void method1()
        {
            
for (int i=0;i<100;++i)
            {
                Console.WriteLine(
"a");
            }
        }

        
public static void method2()
        {
            
for (int i=0;i<100;++i)
            {
                Console.WriteLine(
"b");
            }
        }
    }
}

 

posted @ 2009-12-10 19:01  eping  阅读(322)  评论(0编辑  收藏  举报