[SPARK-4813][Streaming] Fix the issue that ContextWaiter didn't handle 'spurious wakeup'

Used `Condition` to rewrite `ContextWaiter` because it provides a convenient API `awaitNanos` for timeout.
It seems a little counterintuitive that `isTerminated` would have three outputs: `true`, `false`, or `Exception`.  The alternative is a bit weird, though: we'd have to have something like `isTerminatedWithError` or `hasError` to distinguish between the two cases.

Sorry for being so nitpicky here, but I'm just trying to reason out what's the most consistent public API for this use case.