增加线程优先级 [英] Increasing Thread Priority

查看:102
本文介绍了增加线程优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

增加线程的优先级是否会使它更快地完成工作?

Does increasing the priority of a thread cause it to finish it''s work faster?

推荐答案

也许.也许不是.

它不会使它运行得更慢,但这就是您所能说的!

为什么不?原因如下:
1)查看您的PC的任务管理器,然后选择进程"选项卡.单击CPU以通过减少CPU使用率对显示进行排序.哪个进程最合适,而您的CPU占98%或99%? 系统空闲过程"-即,当根本没有其他事情可做时,只有完成任务的任务!如果您仍然是唯一使用线程的进程,那么增加线程优先级将不会给您更多的CPU!
2)无论如何,您的线程可能实际只需要执行很少的CPU处理:您可能主要是在等待磁盘访问,其他进程,外部数据库等,等等.更改优先级不会对它们产生最小的影响! >
总的来说,答案是可能不会",但是您可能需要尝试一下以找出是否适合您的具体情况.
Maybe. Maybe not.

It won''t make it run any slower, but that''s about all you can say!

Why not? Here are a few reasons:
1) Have a look at your PC''s Task Manager, and select the "Processes" Tab. Click on CPU to sort the display by decreasing CPU usage. What process is right at the top, with 98 or 99 percent of your CPU? "System Idle Process" - i.e. the task that only ever gets a go when there is nothing else to do at all! Increasing your thread priority won''t give you more CPU if you are the only process using it anyway!
2) Your thread may have very little actual CPU processing to do anyway: you could be mostly waiting for disk access, other processes, external databases, etc., etc.. Changing your priority will not affect these in the least!

On balance, the answer is "probably not", but it may be worth your experimenting to find out if it does in your specific case.


要添加到Griff的答案中,您可以应该避免这样做.如果增加线程的优先级,它将从所有其他正在运行的线程中窃取时间片,并且您可能会在此过程中扰乱其他(看不见的)应用程序苹果购物车...
To add to Griff''s answer, you should avoid doing it. If you increase the priority on your thread, it steals time slices from all other running threads, and you could upset other (unseen) application apple carts in the process...


这篇关于增加线程优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆