title: The proper way to handle exceptions thrown by the SwingWorker.doInBackground
body: <p>The proper way to handle exceptions thrown by the <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/SwingWorker.html#doInBackground()" rel="nofollow noreferrer"><code>doInBackground</code></a> method of <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/SwingWorker.html" rel="nofollow noreferrer"><code>SwingWorker</code></a> class is to invoke the <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/SwingWorker.html#get()" rel="nofollow noreferrer"><code>get</code></a> method from within the <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/SwingWorker.html#done()" rel="nofollow noreferrer"><code>done</code></a> method, as explained <a href="https://stackoverflow.com/a/6524300/364056">here</a> and <a href="https://stackoverflow.com/a/13942919/364056">here</a>.</p>
  
  <p>The documentation for the <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/SwingWorker.html#get()" rel="nofollow noreferrer"><code>get</code></a> method states the following:</p>
  
  <blockquote>
    <p>Waits if necessary for the computation to complete, and then retrieves
    its result.</p>
    
    <p>Note: calling <code>get</code> on the <em>Event Dispatch Thread</em> blocks <em>all</em>
    events, including repaints, from being processed until this
    <code>SwingWorker</code> is complete.</p>
  </blockquote>
  
  <p>Therefore, if the <code>get</code> method causes a waiting within the <code>done</code> method, in fact it would block the Event Dispatch Thread, since the <code>done</code> method is executed on EDT.</p>
  
  <p>However, after performing a simple test of the proposed solution, you may notice that the EDT is not blocked: this behavior occurs because the <code>get</code> method is invoked within the <code>done</code> method, so <code>get</code> is invoked after the result of the operation was calculated, and therefore the call to it will not block the EDT. Is this motivation correct?</p>