Do spurious wakeups affect calls to 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?
You're asking whether Thread.sleep()
is affected by the same spurious wakeup issue that is documented to affect Object.wait(long)
, right? The answer is that there is no documented spurious wakeup associated with Thread.sleep()
. You're right that no hard guarantees are made about exactly how long you'll sleep when you request N milliseconds. Also, of course, Thread.sleep()
terminates on thread interrupt.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With