Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8333433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:01:48+00:00 2026-06-09T03:01:48+00:00

Thread dump contains wealth of information. For example, if I suspect some action fired

  • 0

Thread dump contains wealth of information. For example, if I suspect some action fired more than once, then all I need to do is dumping stack trace each time the action is fired, then investigate the stacks for erroneous action firing.

In certain situations developers are encouraged to abandon conceptual simplicity of sequential execution. For example, Swing offers SwingWorker helper to work around limitations of single threaded EDT. Now, if I dump stack trace, it is useless, because the action is fired by SwingWorker, and there is no information on who initiated SwingWorker task.

So, how do I troubleshoot? Is there a clever trick of “redirecting” thread dump to follow the genuine cause?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:01:50+00:00Added an answer on June 9, 2026 at 3:01 am

    You can extend SwingWorker to record the stack when it is created (or when execute but then you need to create another execute method since it is final). Creating the cause is relative expensive though so you might want to do it only when debug (check log level or some such)

    import java.util.concurrent.ExecutionException;
    import javax.swing.SwingWorker;
    
    public abstract class TracedSwingWorker<T, V> extends SwingWorker<T, V> {
    
        private final Exception cause;
    
        public TracedSwingWorker() {
            super();
            this.cause = new Exception("TracedSwingWorker created at:");
        }
    
        @Override
        protected final T doInBackground() throws Exception {
            try {
                return doWorkInBackground();
            }
            catch(Exception e) {
                if(this.cause != null) {
                    Throwable cause = e;
                    while(cause.getCause() != null) {
                        cause = cause.getCause();
                    }
    
                    cause.initCause(this.cause);
                }
    
                throw e;
            }
        }
    
        protected abstract T doWorkInBackground();
    
        // just for testing
        public static void main(String[] args) {
            new TracedSwingWorker<Void, Void>() {
                @Override
                protected Void doWorkInBackground() {
                    throw new IllegalArgumentException("Exception in TracedSwingWorker!");
                }
    
                @Override
                protected void done() {
                    try {
                        get();
                    }
                    catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    catch (ExecutionException e) {
                        e.printStackTrace();
                    }
                }
            }.execute();
        }
    }
    

    prints:

    java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Exception in SwingWorker!
            at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
    <snip>
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
            at java.lang.Thread.run(Thread.java:662)
        Caused by: java.lang.Exception: SwingWorker created at:
            at TracedSwingWorker.<init>(TracedSwingWorker.java:15)
            at TracedSwingWorker$2.<init>(TracedSwingWorker.java:60)
            at TracedSwingWorker.main(TracedSwingWorker.java:60)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently we are analyzing a tomcat thread dump. A single thread dump of all
I got a thread dump of one of my processes. It has a bunch
So far I have learned about generating thread dump and heap dump using jstack
Is it possible to see thread performance counters in dump of native c++ application
Main thread of application is doing some work. There also exists a timer, which
does java 6 generate thread dump in addition to heap dump (java_pid14941.hprof) this is
I managed to generate thread dump when my test case hanging. However, it doesn't
I need UI thread dump for Eclipse RCP application. Could you please help on
My tomcat (running in linux/ubuntu) crashes sometimes with a thread dump appended to catalina.out.
Is there a way to get a thread dump from a running Python process?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.