多线程 - java thread yield 的设计目的是什么?

查看:122
本文介绍了多线程 - 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.
你基本找不到用它的时候。

这篇关于多线程 - java thread yield 的设计目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆