Description
According to javadocs,
A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:
synchronized (obj)
Unknown macro: { while (<condition does not hold>) obj.wait(timeout); ... // Perform action appropriate to condition }
`wait` should always occur in loops.
But now ContextWaiter.waitForStopOrError doesn't.
def waitForStopOrError(timeout: Long = -1) = synchronized { // If already had error, then throw it if (error != null) { throw error } // If not already stopped, then wait if (!stopped) { if (timeout < 0) wait() else wait(timeout) if (error != null) throw error } }
Attachments
Issue Links
- relates to
-
SPARK-5379 Add awaitTerminationOrTimeout
- Resolved
- links to