SwingWorker Hanging

My program was hanging; I thought it was caused by the deadlock; but as it turns out it was some exception that was never shown ūüôĀ

This particular behavior was explained in this post:

A few things to remember, though: the¬†done()¬†method is NOT abstract, so you aren’t required to override it. You should, though. If your¬†doInBackground()¬†implementation throws an exception, that exception will be swallowed unless¬†done()¬†has been overridden.¬†Also, don’t make changes to your GUI from inside the¬†doInBackground(), unless you useSwingUtilities.invokeLater(Runnable), as¬†doInBackground()¬†is executed from a different thread than the EDT and making GUI changes from a background thread is asking for strange and inexplicable bugs.

Note that you need to call the get() method; I have solved this problem by adding the following to the class extending SwingWorker:

    @Override
    protected void done(){
        try {
            get();
        } catch (InterruptedException ex) {
            Exceptions.printStackTrace(ex);
        } catch (ExecutionException ex) {
            Exceptions.printStackTrace(ex);
        }
    }

 

 

 

Keywords & References

Searched for swingworker swallow exception stackoverflow 8:48pm
java – How to wait for object creation…¬†–¬†stackoverflow.com 8:48pm
Searched for swingworker swall exception stackoverflow 8:48pm
Searched for swingworker swall exception 8:48pm
Searched for swingworker does not throw exception 8:44pm
A better SwingWorker without exception…¬†–¬†baptiste-wicht.com 8:44pm
The Last Word in Swing Threads¬†–¬†sun.com 8:45pm
Swing Tip : A Better SwingWorker Without…¬†–¬†dzone.com 8:45pm
Searched for swingworker does not throw excepction 8:44pm
Searched for swingworker throw exception doInBackground 8:43pm
SwingWorker and exceptions in the doInBackgro…¬†–¬†velocityreviews.com 8:43pm
Searched for swingworker throw exception 8:42pm
java – How should I handle exceptions…¬†–¬†stackoverflow.com 8:42pm
java – Gracefull exception handling in…¬†–¬†stackoverflow.com 8:42pm
Searched for swingworker exception in doinbackground 8:40pm
A SwingWorker that doesn’t swallow exceptions…¬†–¬†jonathangiles.net 8:40pm
Searched for casting hangs swingworker 8:35pm
Searched for java thread vs swingworker 8:19pm
SwingWorker (Java Platform SE 6)¬†–¬†oracle.com 8:20pm
Improve Application Performance With…¬†–¬†sun.com 8:20pm
java – Why SwingWorker? Why not just…¬†–¬†stackoverflow.com 8:20pm
java – To use or not to use a SwingWorker…¬†–¬†stackoverflow.com 8:20pm
SwingWorker – Wikipedia, the free encyclopedia¬†–¬†wikipedia.org
Searched for java thread 8:19pm
Lesson: Concurrency (The Java‚ĄĘ Tutorials…¬†–¬†oracle.com 8:19pm
Searched for hashmap clone 8:13pm
clone utility for HashMap in java – Stack…¬†–¬†stackoverflow.com 8:13pm
Searched for swingworker hangs hashmap 8:04pm
multithreading – Java GUI threads – SwingWork…¬†–¬†stackoverflow.com 8:04pm
java – Is this SwingWorker not reusing…¬†–¬†stackoverflow.com 8:04pm
Searched for swingworker hangs 8:03pm
swing – Java SwingWorker hanging – Stack…¬†–¬†stackoverflow.com¬†–¬†Viewed 2 times 8:03pm
multithreading – Java GUI Freezes even…¬†–¬†stackoverflow.com 8:03pm
Lesson: Concurrency in Swing (The Java‚ĄĘ…¬†–¬†oracle.com 8:03pm
How To Solve The Hang Problem ? – Java…¬†–¬†dreamincode.net 8:03pm
Hidden Java 7 Features ‚Äď SecondaryLoop…¬†–¬†sellmic.com 8:04pm
(Tutorial) Using SwingWorker – A Step…¬†–¬†indijava.in 8:04pm
SwingWorker problem¬†–¬†java-forums.org 8:04pm
http://swing.resourcezen.com/how-to-tell-some… 8:04pm
Searched for Float.valueOf 7:59pm
Float (Java 2 Platform SE v1.4.2)¬†–¬†oracle.com 7:59pm
Searched for java transient 7:57pm
Searched for java Runnable 7:48pm
Runnable (Java 2 Platform SE v1.4.2)¬†–¬†oracle.com 7:48pm
Searched for java new object hangs swingworker 7:45pm
swing – Java SwingWorker hanging – Stack…¬†–¬†stackoverflow.com¬†–¬†Viewed 2 times 7:45pm
Searched for HashMap 7:18pm
HashMap (Java Platform SE 6)¬†–¬†oracle.com
Searched for hashtable synchronized 7:17pm
java – Differences between HashMap and…¬†–¬†stackoverflow.com 7:17pm
Searched for hashtableset java 6:53pm
Searched for java hashtable 6:52pm
Hashtable (Java Platform SE 6)¬†–¬†oracle.com 6:52pm
Searched for java super constructor 6:47pm
Using the Keyword super (The Java‚ĄĘ…¬†–¬†oracle.com 6:47pm
Searched for java float 6:29pm
Float (Java Platform SE 6)¬†–¬†oracle.com 6:29pm
Searched for java float double 6:29pm
Searched for swing panel field properties 6:14pm
Change JText Field properties through…¬†–¬†stackoverflow.com 6:15pm
Searched for java properties 5:44pm
Properties (Java Platform SE 6)¬†–¬†oracle.com 5:44pm
Searched for data model 4:56pm
Data model – Wikipedia, the free encyclopedia¬†–¬†wikipedia.org 4:56pm
Searched for analytics 2:07pm
Google Analytics | Official Website¬†–¬†google.com¬†–¬†Viewed 246 times 2:07pm
Searched for JPanel java 1:53pm
JPanel (Java 2 Platform SE 5.0)¬†–¬†oracle.com 1:53pm
Searched for get values of all components panel 1:51pm
swing – Java get JPanel Components -…¬†–¬†stackoverflow.com 1:52pm
Searched for swing panel get all fields 1:51pm
Searched for swing panel get all input field 1:51pm
Searched for swing panel input field properties

 

 

 

 

 

 

About Neil Rubens

see http://ActiveIntelligence.org

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*