title: Should my custom events fire on GUI EDT or a "home-grown" EDT
body: <p>I'm working on a project that does some intense math calculations (arrays of matrices, vectors, etc.), so naturally I'm splitting the work into jobs, and submitting them to a CompletionService to perform the work in parallel.</p>
  
  <p>Each of the job objects can fire events to notify applications when the job starts, ends, progresses, and/or fails.</p>
  
  <p>Currently, each of the jobs receive a handle to the entire list of event listeners, and simply iterate through, passing an event object to each one (in the same thread). This doesn't sit well with me, so I'd like to get other peoples' experience with doing this sort of thing with custom events/listeners.</p>
  
  <p>Should I send my events to the GUI thread? Some of the listeners may or may not be GUI-related, and I'd like to not force users of my code to have to manually send their events onto the GUI thread, something like the following:</p>
  
  <pre><code>public class MyFooEventListener implements FooEventListener {
      public void notifyJobStarted(FooEvent evt) {
          // I want to avoid having users of my library write the following, right?
          SwingUtilities.invokeLater(new Runnable(){
              // update GUI here.
          });
      }
  }
  </code></pre>
  
  <p>I wouldn't mind writing my own EventQueue, as this is for a research project in school, and I suppose it would be a good exercise in concurrency. Just trying to figure out what the "proper" way of implementing an event-driven system is, how to properly fire events, etc. Links to articles/tutorials and howtos are also greatly appreciated.</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>My event model has multiple event types, such as <code>JobStartedEvent</code>, <code>JobEndedEvent</code>, <code>JobProgressEvent</code>, etc. Is this a bad approach? Should I have a single event type, and if so, how do I pass information to the listeners that is not common to all events? Example: I want to pass a double in the range [0-1] for the progress event, but that is not applicable for an event like JobFailureEvent. What's the best approach to handling this?</p>
  
  <p>I could put the extra information in the "source" object itself, but my source objects are the Job objects themselves, and it doesn't sit well with me to "leak" references to the job object, especially while it is running:</p>
  
  <pre><code>FooJob jobObject = (FooJob)event.getSource();
  int progressPercent = jobObject.getCurrentProgress() * 100;
  progressLabel.setText(progressPercent + "%");
  </code></pre>