首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >线程优先级算法的正确性

线程优先级算法的正确性
EN

Stack Overflow用户
提问于 2014-12-15 15:41:37
回答 1查看 87关注 0票数 0

我读到线程优先级算法的正确性并不总是有保证的,因为它依赖于JVM。为什么会这样?它是如何依赖于JVM的?

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2014-12-15 18:00:41

线程优先级效果是特定于平台的。应该避免使用这些优先级,因为它们可能会导致活性问题,并且它们的效果并不明显。

来自实践中的Java并发性:

代码语言:javascript
运行
复制
The thread priorities defined in the Thread API are merely scheduling hints.The Thread
API defines ten priority levels that the JVM can map to operating system scheduling
priorities as it sees fit. This mapping is platform‐specific, so two Java priorities
can map to the sameOS priority on one system and different OS priorities on another.

...

The thread priority mechanism is a blunt instrument, and it's not always obvious what
effect changing priorities will have; boosting a thread's priority might do nothing or
might always cause one thread to be scheduled in preference to the other, causing
starvation.

结论:

代码语言:javascript
运行
复制
Avoid the temptation to use thread priorities, since they increase platform 
dependence and can cause liveness problems. Most concurrent applications can use
the default priority for all threads.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27479385

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档