本文介绍了同步块内的产量?调用yield()之后锁定释放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建多个线程并在其中调用yield()
.
I am creating a multiple threads and calling yield()
inside it.
是否也可能要执行其他也要进入同步块的线程?
Will It be possible for other threads to execute which also want to go inside synchronized block?
synchronized(this.lock)
{
//calling yield here.
}
谢谢.
推荐答案
据我所知,Yield()仅放弃CPU上的剩余时间片,并退回到队列中.它不会释放任何同步对象.
As far as I know, Yield() only gives up the remaining time slice on the CPU and steps back in the queue. It doesn't release any synchronized objects.
这篇关于同步块内的产量?调用yield()之后锁定释放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!