How to get the family tree of all the threads?
David Holmes
David.Holmes at Sun.COM
Thu Oct 29 04:39:06 PDT 2009
Hi Tony,
> I am working on a project where I need to identify the relations
> between parent threads and children threads. Especially, I want to do
> it inside the JVM, not in a java program.
As others have said you need to do this yourself by monitoring thread
construction and/or starting.
In Java there is no parent/child relationship between threads - all threads
are considered equal siblings. This is in contrast to other systems where
"child" threads are an explicit notion where exceptions in a child can be
caught in a parent; where joining a parent joins all children etc. But
that's not Java.
Cheers,
David Holmes
> Looking at the code of hotspot, I can only find the thread list inside
> the Thread class, but it's not enough for my purpose.
>
> Is there some way that I can draw out a family tree of the threads
> within the hotspot? I know that from within a java program, we can
> draw a tree of all the ThreadGroups, but it again is not what I want.
>
> Or could you tell me how I could identify when a thread is created,
> and who is the parental thread that creates it?
>
> Thanks a lot!
>
> Tony Guan
More information about the hotspot-dev
mailing list