using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace CpuTest
{
public class ThreadPriorityExample1
{
public static bool loopover = false;
public static void ThreadMethod()
{
long count = 0;
while (loopover)
{ count++; }
Console.WriteLine("{0} 优先级为: {1}" + "计数为: {2}", Thread.CurrentThread.Name, Thread.CurrentThread.Priority.ToString(), count.ToString());
}
}
class Program
{
static void Main(string[] args)
{
ThreadStart ts = new ThreadStart(ThreadPriorityExample1.ThreadMethod);
Thread t1 = new Thread(ts);
t1.Name = "子线程1";
Thread t2 = new Thread(ts);
t2.Name = "子线程2";
t1.Priority = ThreadPriority.BelowNormal;
t1.Start();
t2.Start();
Thread.Sleep(100);
ThreadPriorityExample1.loopover = true;
Console.Read();
}
}
}
帮我看看上面的程序的结果,谢谢!!主要是那个count的值
程序功能是用来反映不同优先级的线程获得CPU的时间情况