java thread yield 的设计目的是什么?

如题,java thread yield 的设计目的是什么?有什么实际应用场景吗?

Ps:它的作用是理解的,和 join 等的区别也理解。就是个人感觉这个设计有点鸡肋(可能是个人读书太少...)

It is rarely appropriate to use this method. It may be useful for debugging or testing purposes, where it may help to reproduce bugs due to race conditions. It may also be useful when designing concurrency control constructs such as the ones in the java.util.concurrent.locks package.
你基本找不到用它的时候。

如果你觉得一个线程不是那么重要,或者优先级非常低,而且又害怕它会占用太多的CPU资源,那么可以在适当的时候调用Thread.yield(),给予其他重要线程更多的工作机会。

原文地址:https://www.cnblogs.com/shamo89/p/8847077.html