[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.
Maybe it's just me but it feels like these loops would be simpler just testing `while (!stopped && error == null)`? `nanos` would be tested in the other one too. This avoids duplication, and also avoids the unreachable return value, because you check these conditions in one place at the end.