首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

深入理解Thread#yield

2012-08-21 
深入了解Thread#yieldIt is rarely appropriate to use thismethod. It may be useful for debugging or t

深入了解Thread#yield


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.

?

描述的更清晰易懂了。

?


同时,RednaxelaFX 还提到:“HotSpot VM的当前版本(JDK6、JDK7)的Linux版里的Thread.yield()实现默认跑到最底下是sched_yield(),http://www.kernel.org/doc/man-pages/online/pages/man2/sched_yield.2.html;同版本里Thread.sleep(0)会转换为跟Thread.yield()等价的行为,也是调用到sched_yield()”。

热点排行