Ah I see what you're saying -- in both cases, the set of waiting stages will be read (by a listener) in a different thread than the list is modified (by the DAGScheduler main loop) so there could be concurrency issues -- but with the current waiting variable, the listeners could read it when waiting is empty, which would be more bad.  But in either case -- this seems like an issue, because the HashSet implementation isn't thread safe.

It might be better to instead implement this by adding a SparkListenerStageCreated event, that sends the listeners Stages as they are made, and let the listeners handle making a set of these.  This avoids the concurrency issue, and is more consistent with the rest of the SparkListener events.  @pwendell should weigh in here though since he's the authority on the SparkListener/UI.