Rémi Forax wrote:
Le 21/11/2009 07:48, Paulo Levi a écrit :
But i'm wondering why there isn't a global jvm system option for the
new Thread(runnable).start() to perserve stack traces at least until
the start method.
You don't need the VM for that, something like that should work:
public class ThreadEx extends Thread {
I believe you can do it non-invasively using (evil)
InheritableThreadLocal as something like:
private static final InheritableThreadLocal<StackTraceElement[]>
stacks = new InheritableThreadLocal<StackTraceElement[]>() {
@Override StackTraceElement[] childValue(
StackTraceElement[] parentValue
) {
return new Throwable().getStackTrace();
}
};
You will need to install into parent threads by calling get.
I have not compiled or tested this code.
Of course, if you are using thread pools (you are, right?) then thread
creation point is mostly meaningless.
Tom Hawtin