2
所以我在我的应用程序中使用线程。我想对我的部分代码进行基准测试,我发现代码在主线程上的运行速度明显加快了2-3倍。更改线程优先级 - Unity 3d
我想调整我创建的线程的线程优先级,但由于某些原因的优先级保持不变 - 总是最低。
代码:
public static void RunTest()
{
Thread thread = new Thread(Fun);
Debug.Log("thread.Priority before change: " + thread.Priority);
thread.Priority = System.Threading.ThreadPriority.Normal;
Debug.Log("thread.Priority after change:" + thread.Priority);
thread.Start();
}
static void Fun()
{
Debug.Log("I am running on a separate thread!");
Debug.Log("Current thread: " + Thread.CurrentThread.Priority);
}
我总是得到 “最低” - 在所有3个案件。
如何更改线程的优先级团结?