[SPARK-4859][Core][Streaming] Improve LiveListenerBus and StreamingListenerBus

Changes to LiveListenerBus and StreamingListenerBus:
* Fix the race condition of `queueFullErrorMessageLogged`.
* Make sure the SHUTDOWN message will be delivered to `listenerThread`.

Changes only to StreamingListenerBus:
* Log the error from listener rather than crashing `listenerThread`.
This does not use `stopped` like the `LiveListenerBus`. I know that introducing `eventLock` and using `eventQueue.poll` instead of `eventQueue.take` like the LiveListenerBus is too much for this PR. But at least we can eliminate the bug related to `StreamingListenerShutdown` by using `stopped` instead of `StreamingListenerShutdown`.