多线程04-ThreadPriority
Posted shidengyun
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了多线程04-ThreadPriority相关的知识,希望对你有一定的参考价值。
class Program
{
static void Main()
{
//没啥作用,除非你 限制一个进程,把线程都在里面跑,限制住一个cpu内核..
Thread t = new Thread(ShowMessage);
t.Name = "One";
//最高等级
t.Priority = ThreadPriority.Highest;
//最低等级
Thread t1 = new Thread(ShowMessageNoSleep);
t1.Name = "Second";
t1.Priority = ThreadPriority.Lowest;
t.Start();
t1.Start();
Console.ReadKey();
}
static void ShowMessage()
{
for (var i = 0; i < 10; i++)
{
Thread.Sleep(1000);
Console.WriteLine(i);
}
}
static void ShowMessageNoSleep()
{
for (var i = 0; i < 10; i++)
{
Console.WriteLine(i);
}
}
}
{
static void Main()
{
//没啥作用,除非你 限制一个进程,把线程都在里面跑,限制住一个cpu内核..
Thread t = new Thread(ShowMessage);
t.Name = "One";
//最高等级
t.Priority = ThreadPriority.Highest;
//最低等级
Thread t1 = new Thread(ShowMessageNoSleep);
t1.Name = "Second";
t1.Priority = ThreadPriority.Lowest;
t.Start();
t1.Start();
Console.ReadKey();
}
static void ShowMessage()
{
for (var i = 0; i < 10; i++)
{
Thread.Sleep(1000);
Console.WriteLine(i);
}
}
static void ShowMessageNoSleep()
{
for (var i = 0; i < 10; i++)
{
Console.WriteLine(i);
}
}
}
以上是关于多线程04-ThreadPriority的主要内容,如果未能解决你的问题,请参考以下文章