Maybe i'm being naive about Threads.
Thomas Hawtin
Thomas.Hawtin at Sun.COM
Sun Nov 22 06:56:59 UTC 2009
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
More information about the core-libs-dev
mailing list