Thread priority does not work as expected?

心已入冬 提交于 2019-12-02 03:29:44

Actually, the behavior of Thread Priority isn't guaranteed. Changing the priority is just a hint / suggestion to the underlying OS that can be totally ignored. A thread with low priority can get more CPU cycles than a thread with high priority. So, bottom line- don't write critical code based on Thread priority.

What @TheLostMind told you is all true, but here's something else to consider.

If your computer has more CPUs than you have runnable threads, then all of the runnable threads are going to be allowed to run. Priority (if it matters at all) can only matter when the threads are in contention for a scarce resource.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!