实现很简单就不做说明了

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace backGroundThread
{
    
class Program
    {
        
static void Main(string[] args)
        {
            Thread tl 
= new Thread(ThreadMain);
            tl.Name 
= "123";
            tl.IsBackground 
= true;//设置为后台线程
            tl.Start();
            Console.WriteLine(
"Main thread ending now ...");
        }
        
static void ThreadMain()
        {
            Console.WriteLine(
"Thread {0} started",Thread.CurrentThread.Name);
            Thread.Sleep(
3000);
            Console.WriteLine(
"Thread {0} completed", Thread.CurrentThread.Name);
        }
    }

} 

posted on 2011-05-10 21:34  jackdesk  阅读(168)  评论(0编辑  收藏  举报