123

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div id="answer-791406" class="answer downvoted-answer accepted-answer" data-answerid="791406" itemscope="" itemtype="http://schema.org/Answer" itemprop="acceptedAnswer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input type="hidden" name="_id_" value="791406">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post " title="View upvote and downvote totals" style="cursor: pointer;">-3</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


        <span class="vote-accepted-on load-accepted-answer-date" title="loading when this answer was accepted...">accepted</span>
</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<p>I guess you don't get many of these question with C#. You need to understand what the exception is and deal with it appropriately (which is usually to let it go further up the stack).</p>

<p><code>InterruptedException</code> - Thrown when a thread is interrupted (by <code>Thread.interrupt</code>) when waiting (roughly). Why would you want a thread to be interrupted? Usually you want the thread to stop what it's doing - reset the interrupt state and exit. For instance, the PlugIn will interrupt applet threads if they continue for much longer after an applet should be gone. However, in this case provided <code>done</code> is called correctly you shouldn't be waiting at all. Therefore, it would be appropriate to wrap the exception in an <code>IllegalStateException</code> (and the API docs should probably state that). It's a really bad API. The <code>publish</code>/<code>process</code> mode probably makes more sense.</p>

<p><code>ExecutionException</code> - You need to deal with the wrapped exception. If you are not expecting a particular type of exception, wrap it in an unchecked exception.</p>

<p>Generally I would suggest a clear separation between what happens on the EDT and what happens off the EDT. Therefore, avoid <code>SwingWorker</code> in production code.</p>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="/a/791406/1150683" title="short permalink to this answer" class="short-link" id="link-post-791406">share</a><span class="lsep">|</span><a href="/posts/791406/edit" class="edit-post" title="revise and improve this post">edit</a><span class="lsep">|</span><a href="#" class="flag-post-link" title="flag this post for serious problems or moderator attention" data-postid="791406">flag</a>
  <div id="popup-flag-post" class="popup" data-postid="791406" style="position: absolute; top: -250px; left: 0; overflow:hidden; max-width: 600px; display: none;z-index: 4;">
    <div class="popup-close"><a title="close this popup (or hit Esc)">×</a></div>
    <form>
        <div>
            <h2 style="margin-bottom: 12px; cursor: move;" class="handle">
                I am flagging this answer because
            </h2>
            <ul class="action-list">
        <li class="">
            <label>
                    <input type="radio" name="top-form" value="PostSpam">
                <span class="action-name">    it is spam
</span>
                <span class="action-desc">
                        This answer is effectively an advertisement with no disclosure. It is not useful or relevant, but promotional.

                </span>
                            </label>
        </li>
        <li class="">
            <label>
                    <input type="radio" name="top-form" value="PostOffensive">
                <span class="action-name">    it is offensive, abusive, or hate speech
</span>
                <span class="action-desc">
                        This answer contains content that a reasonable person would deem inappropriate for respectful discourse.

                </span>
                            </label>
        </li>
        <li class="">
            <label>
                    <input type="radio" name="top-form" value="AnswerNotAnAnswer">
                <span class="action-name">    it is not an answer
</span>
                <span class="action-desc">
                        This was posted as an answer, but it does not attempt to answer the question. It should possibly be an edit, a comment, another question, or deleted altogether.

                </span>
                            </label>
        </li>
        <li class="">
            <label>
                    <input type="radio" name="top-form" value="PostLowQuality">
                <span class="action-name">    it is very low quality
</span>
                <span class="action-desc">
                        This answer has severe formatting or content problems. This answer is unlikely to be salvageable through editing, and might need to be removed.

                </span>
                            </label>
        </li>
        <li class="">
            <label>
                    <input type="radio" name="top-form" value="PostOther">
                <span class="action-name">    other (needs ♦ moderator attention)
</span>
                <span class="action-desc">
                        This answer needs a moderator's attention. Please describe exactly what's wrong.

                </span>
                                    <div class="action-subform mod-attention-subform" style="margin:5px 0px; width:auto">
                        <div style="margin-left: 18px;">
                            <textarea name="otherText" cols="80" rows="3" style="display: block; margin-bottom: 5px;" placeholder="Something not quite right? Let us know about it, and please provide relevant links if possible."></textarea>
                            <span class="text-counter"></span>
                        </div>
                    </div>
            </label>
        </li>
            </ul>
        </div>
        <div class="popup-actions">

            <div style="float:right">
                <span class="flag-remaining-inform" style="padding-right:20px">
                    <span class="bounty-indicator-tab supernovabg" style="line-height:20px;" title="flags remaining today, UTC">
                        17
                    </span>flags remaining
                </span>
                <span class="spinner-container"></span>
                <input type="submit" class="popup-submit" style="float:none; margin-left:5px;" value="Flag Answer" disabled="disabled">
            </div>
        </div>
    </form>
</div></div>                    </td>
            


    <td align="right" class="post-signature">   
       

    <div class="user-info user-hover">
    <div class="user-action-time">
        answered <span title="2009-04-26 19:07:09Z" class="relativetime">Apr 26 '09 at 19:07</span>
    </div>
    <div class="user-gravatar32">
        <a href="/users/4725/tom-hawtin-tackline"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/1b562e4138eb93217d7af77ccb8402b8?s=32&amp;d=identicon&amp;r=PG" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="/users/4725/tom-hawtin-tackline">Tom Hawtin - tackline</a><br>
        <span class="reputation-score" title="reputation score 90095" dir="ltr">90.1k</span><span title="14 gold badges"><span class="badge1"></span><span class="badgecount">14</span></span><span title="126 silver badges"><span class="badge2"></span><span class="badgecount">126</span></span><span title="222 bronze badges"><span class="badge3"></span><span class="badgecount">222</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-791406" class="comments ">
		    <table>
                <tbody data-remaining-comments-count="3" data-canpost="true" data-cansee="false" data-comments-unavailable="false" data-addlink-disabled="false">



    <tr id="comment-602601" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of 'useful comment' votes received" class="cool">1</span>
                        </td>
                        <td>
                                <a class="comment-up comment-up-off" title="this comment adds something useful to the post">upvote</a>
                        </td>
                    </tr>
                        <tr>
                            <td>&nbsp;</td>
                                <td>
                                    <a class="comment-flag" title="Flag this comment for serious problems or moderator attention">flag</a>
                                </td>
                        </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">Why avoid SwingWorker in production code?  Sun promotes it  <a href="http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html" rel="nofollow">java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html</a></span>
                –&nbsp;
                    <a href="/users/57752/eddie" title="30494 reputation" class="comment-user">Eddie</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment602601_791406"><span title="2009-04-27 04:35:13Z" class="relativetime-clean">Apr 27 '09 at 4:35</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-602994" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                <a class="comment-up comment-up-off" title="this comment adds something useful to the post">upvote</a>
                        </td>
                    </tr>
                        <tr>
                            <td>&nbsp;</td>
                                <td>
                                    <a class="comment-flag" title="Flag this comment for serious problems or moderator attention">flag</a>
                                </td>
                        </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">Avoid SwingWorker because it is atrocious design. Don't use something just because a company tells you to.</span>
                –&nbsp;
                    <a href="/users/4725/tom-hawtin-tackline" title="90095 reputation" class="comment-user">Tom Hawtin - tackline</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment602994_791406"><span title="2009-04-27 08:41:32Z" class="relativetime-clean">Apr 27 '09 at 8:41</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-623785" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of 'useful comment' votes received" class="cool">4</span>
                        </td>
                        <td>
                                <a class="comment-up comment-up-off" title="this comment adds something useful to the post">upvote</a>
                        </td>
                    </tr>
                        <tr>
                            <td>&nbsp;</td>
                                <td>
                                    <a class="comment-flag" title="Flag this comment for serious problems or moderator attention">flag</a>
                                </td>
                        </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">Tom, the new framework in Java 6 was implemented in order to add greater flexibility to the existing framework.  For example, in Java 6 you can actually populate a JTable with massive amount of data as the data is being loaded.  Although it should be used when appropriate its kind of far fetch to recommend to avoid it.  None of your suggested alternatives can do what the Java 6 was designed for.</span>
                –&nbsp;
                    <a href="/users/88252/jeach" title="2038 reputation" class="comment-user">Jeach</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment623785_791406"><span title="2009-05-02 05:50:52Z" class="relativetime-clean">May 2 '09 at 5:50</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-624086" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of 'useful comment' votes received" class="cool">1</span>
                        </td>
                        <td>
                                <a class="comment-up comment-up-off" title="this comment adds something useful to the post">upvote</a>
                        </td>
                    </tr>
                        <tr>
                            <td>&nbsp;</td>
                                <td>
                                    <a class="comment-flag" title="Flag this comment for serious problems or moderator attention">flag</a>
                                </td>
                        </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">You could always retrieve data in the background (although in Java 1.1 there was no EventQueue.invokeLater). SwingWorker allows trivial examples to be written with few lines of code. Real code tends to get more complex very quickly. SwingWorker imposes a bad design that tightly couple EDT and non-EDT work.</span>
                –&nbsp;
                    <a href="/users/4725/tom-hawtin-tackline" title="90095 reputation" class="comment-user">Tom Hawtin - tackline</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment624086_791406"><span title="2009-05-02 09:50:28Z" class="relativetime-clean">May 2 '09 at 9:50</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-1212411" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of 'useful comment' votes received" class="cool">2</span>
                        </td>
                        <td>
                                <a class="comment-up comment-up-off" title="this comment adds something useful to the post">upvote</a>
                        </td>
                    </tr>
                        <tr>
                            <td>&nbsp;</td>
                                <td>
                                    <a class="comment-flag" title="Flag this comment for serious problems or moderator attention">flag</a>
                                </td>
                        </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">I think you are wrong. You do want to know if the thread was interrupted. For example, the background task got canceled. Thus, when done is called, you won't be able to retrieve the result, but instead you get an InterruptedException.  It's not an illegal state. It is legal for someone to cancel the background task, and you have to deal with it however it feels appropriate.  I think in the catch clause for the InterruptedException, you should write the handling code considering you were not able to retrieve the data the task was supposed to fetch.</span>
                –&nbsp;
                    <a href="/users/84556/andrei-vajna-ii" title="1603 reputation" class="comment-user">Andrei Vajna II</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment1212411_791406"><span title="2009-09-03 14:26:43Z" class="relativetime-clean">Sep 3 '09 at 14:26</span></a></span>
                                                                            </div>
                    </td>
    </tr>
                </tbody>
				    <tfoot>
					    <tr>
						    <td></td>
						    <td class="comment-form">
							    <form id="add-comment-791406" class="" data-placeholdertext="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”."></form>
						    </td>
					    </tr>
				    </tfoot>
		    </table>
	    </div>

        <div id="comments-link-791406">

                <a class="js-add-link comments-link " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#">add a comment</a><span class="js-link-separator ">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link " title="expand to show all comments on this post, or add one of your own" href="#" onclick="">show <b>3</b> more comments</a>
        </div>         
    </td>
</tr>    </tbody></table>
</div>
            
          
!
            
              @import "compass/css3";

.downvoted-answer {
  position: relative;
  opacity: 1;
  &:after {
    content: "";
    position: absolute;
    z-index: 2;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    background: rgba(255,255,255,0.5);
    pointer-events: none;
  }
  .post-menu {
    position: relative;
    z-index: 3;
  }
}
            
          
!
            
              $(".post-menu a").click(function(e) {
  $("#popup-flag-post").fadeToggle(300);
  e.preventDefault();
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console