zoukankan      html  css  js  c++  java
  • 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(),给予其他重要线程更多的工作机会。

  • 相关阅读:
    PMO的重要性
    idea CPU过高问题
    近期面试心得
    Spring-Eureka
    BIO/NIO
    redis redlock
    nmon 安装及使用 【linux环境】
    一致性hash 算法
    gossip协议了解
    00008
  • 原文地址:https://www.cnblogs.com/shamo89/p/8847077.html
Copyright © 2011-2022 走看看