Redian新闻
>
what is the use of thread.yield()?
avatar
what is the use of thread.yield()?# Java - 爪哇娇娃
e*a
1
what is the use of thread.yield()?
avatar
a*n
2
考试书上抄来的
What yield() is supposed to do is
make the currently running thread head back to runnable to allow other
threads of
the same priority to get their turn. So the intention is to use yield() to
promote
graceful turn-taking among equal-priority threads. In reality, though, the
yield()
method isn't guaranteed to do what it claims, and even if yield() does cause
a
thread to step out of running and back to runnable, there's no guarantee the
yielding
thread won't just be chosen again over all the others! So while yield()
might—and
often does—make a running thread give up its slot to another runnable
thread of the
same priority, there's no guarantee.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。