5

看 Ribbon 轮询的负载策略源码中,循环获取可用服务,使用了 Thread.yield()有什么用...

 3 years ago
source link: https://www.v2ex.com/t/802797
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Java

看 Ribbon 轮询的负载策略源码中,循环获取可用服务,使用了 Thread.yield()有什么用意?

  gengzi · 1 天前 · 421 次点击

while (server == null && count++ < 10) { // 省略。。 if (server == null) { /* Transient. */ Thread.yield(); continue; } // 省略。。 }

看代码应该是 9 年期,难道只是出让一次机会给别的线程执行?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK