[英]Do spurious wakeups affect Thread.sleep?
Do spurious wakeups affect calls to Thread.sleep(x)? 虚假唤醒会影响对Thread.sleep(x)的调用吗? Obviously, the timer is not 100% precise (leading to minor inaccuracies in wakeup times), but is it affected by the spurious wakeup problem? 显然,定时器不是100%精确(导致唤醒时间的微小不准确),但它是否受到虚假唤醒问题的影响?
You're asking whether Thread.sleep()
is affected by the same spurious wakeup issue that is documented to affect Object.wait(long)
, right? 你问Thread.sleep()
是否受到影响Object.wait(long)
的同一个虚假唤醒问题的影响,对吧? The answer is that there is no documented spurious wakeup associated with Thread.sleep()
. 答案是没有与Thread.sleep()
相关的虚假唤醒记录。 You're right that no hard guarantees are made about exactly how long you'll sleep when you request N milliseconds. 你是正确的,当你要求N毫秒时,没有确切的保证你将睡多久。 Also, of course, Thread.sleep()
terminates on thread interrupt. 当然, Thread.sleep()
当然Thread.sleep()
终止线程中断。
real interval of sleep is always >= required interval. 实际的睡眠间隔始终> =所需的间隔。 it is especially sensitive on small intervals. 它对小间隔特别敏感。
now about "spurious wakeups". 现在关于“虚假的唤醒”。 it was not mentioned about Thread.sleep 没有提到Thread.sleep
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.