[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`.
There is a implicit conversion going on between Java's CopyOnWriteArrayList and Scala Iterable/Iterator every time foreach applied. I am not sure whether that conversion is efficient, or if it is copying everything from the underlying array. Might be better to use Java API directly.