使用 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
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP