[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`.
Scala uses JIterableWrapper to wrapper a Java Iterable. It doesn't copy the data. However, using Java Iterator directly will avoid to create a JIterableWrapper every time. So I change to this way now.