博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

C#多线程

Posted on 2010-05-19 16:38  淡如水wp  阅读(347)  评论(0编辑  收藏  举报

 

using System.Threading;

//线程方法

public void ThreadFunc()

{

  
//do some thing;

}



//启动线程(传参数)

int a=1;

ParameterizedThreadStart pts
= new ParameterizedThreadStart(ThreadFunc);

Thread thread
= new Thread(pts);

thread.Start(a);


//启动线程(不传参数)

ThreadStart pts
= new ThreadStart(ThreadFunc);

Thread thread
= new Thread(pts);

thread.Start();