首页  >  文章  >  后端开发  >  C#显示线程优先级的程序

C#显示线程优先级的程序

王林
王林转载
2023-08-31 17:17:021096浏览

C#显示线程优先级的程序

要在 C# 中显示线程的优先级,请使用 Priority 属性。

首先,使用 currentThread 属性显示有关线程的信息 -

Thread thread = Thread.CurrentThread;

现在使用 thread.Priority 属性来显示线程的优先级 -

thread.Priority

示例

让我们看一下在 C# 中显示线程优先级的完整代码。

实时演示

using System;
using System.Threading;
namespace Demo {
   class MyClass {
      static void Main(string[] args) {
         Thread thread = Thread.CurrentThread;
         thread.Name = "My Thread";
         Console.WriteLine("Thread Priority = {0}", thread.Priority);
         Console.ReadKey();
      }
   }
}

输出

Thread Priority = Normal

以上是C#显示线程优先级的程序的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:tutorialspoint.com。如有侵权,请联系admin@php.cn删除