The Javadoc for Object.wait( timeout )
recommends calling wait
in a loop which checks the predicate in order to handle spurious wakeups:
while ( !predicate )
Object.wait( timeout )
This example however doesn't take into account that in the event of a spurious wakeup, timeout would need to be modified on subsequent loop iterations to account for time waited. Pthreads avoids this problem by specifying an absolute time for the timeout. Do I need to handle this myself or is timeout decremented internally?