多线程小实例:
创建一个子线程去完成程序的运行工作
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Studythread2
{
    class Program
    {
        static void Main(string[] args)
        {
     //创建一个线程
            Thread thread = new Thread(new ThreadA().Test);
            //使线程处于就绪状态,没有执行
            thread.Start();
        }
    }
    public class ThreadA
    {
        //子线程,担任程序运行工作
        public void Test()
        {
            for (int i = 0; i < 100;i++ )
            {
                var a = i%2;
                if (a == 1)
                {
                    Console.WriteLine(i);
                }
            }
        }
    }
}

posted on 2012-08-06 21:12  Li-鹤鸣  阅读(102)  评论(0)    收藏  举报