Question: In the client program on which I work, we dispatch server calls to different Threads, to not lock the UI (equivalent of a SwingWorker).

This is made with a model class inheriting an abstract class containing the "update" method, which is preparing the new thread, and executing the code from an abstract method in this newly created Thread (plus other tweaks)

It works correctly, but my issue is that when debugging (or logging), it is hard to keep track of which method exactly called the "update" method, since the stack trace ends with the creation of the new Thread.

**What would be the proper way to keep track of the stack trace which led to call this new Thread?** Ideally, in a way which would show in the debugger's stack navigator (from Eclipse in this case; the idea is to navigate easily in the initial context).

Answer: 
A good way to store a stacktrace away efficiently is to simply construct an exception. Later, if you want to inspect the stacktrace call `exception.getStackTrace()` which will do the slow work of resolving the stack frames to methods.

So, you could create a `new Exception` on the construction of your worker thread, or pass it to the worker thread. Note, you'll have to get eclipse to evaluate exception.getStackTrace(), because the exception object won't have the details before you do.

```
public abstract class Worker {
    protected abstract Object doTheWork();
    public Future<Object> update() {
        Exception stack = new Exception();
        Callable<Object> job = new WhateverYourCallableIs(stack);

        return submitJob(job);
    }
}

```

Incidentally, you should probably use an ExecutorService to manage the lifecycle of your threads.

**Edit**
I'm suggesting this way because it will have a minimal impact on performance in the usual case where you don't want to see the stack trace.
You say you do "like SwingWorker". In this case, why not using an [ExecutorService](http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html) ? Java concurrent framework is pretty well made, and would allow you to avoid the classic pitfalls of threading, amongst them your question.