摘要: 线程的优先级设置或者获得当前线程的优先级:using System;using System.Collections.Generic;using System.Text;using System.Threading;namespace ThreadTest{ class Program { static void Main(string[] args) { // 线程调度 Thread t5 = new Thread(ThreadMethed); // 获取一个值,该... 阅读全文
posted @ 2012-01-15 23:52 金丝猴 阅读(248) 评论(0) 推荐(1) 编辑
摘要: 为线程传递参数,在实际应用中,线程需要得到运行时的参数,然后,在执行相关程序任务。如何为线程执行前,将线程方法中需要的数据进行传递呢?本文将介绍该方法。 有两种方式可以为线程传递相关的参数。我们逐一进行介绍。1.使用带ParameterizedThreadStart委托参数的Thread构造函数例子:1.Thread参数调用using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;namespace ThreadTest{ class P... 阅读全文
posted @ 2012-01-15 23:07 金丝猴 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 线程,其实是很有意思的东西。一个进程可以创建一个或多个线程以执行与该进程关联的部分程序代码。这样对提高程序效率有着至关重要的作用!先看例子:class Program { static void Main(string[] args) { // 简单线程 Thread t1 = new Thread(ThreadStartMethed); t1.Start(); Console.WriteLine(" 主线程-执行 "); Console.ReadLine(); } /// <summary> /// 线程开始时执行的方法 /// </summary> 阅读全文
posted @ 2012-01-15 22:34 金丝猴 阅读(114) 评论(0) 推荐(0) 编辑