How to get the family tree of all the threads?

Christian Thalinger Christian.Thalinger at Sun.COM
Thu Oct 29 02:21:23 PDT 2009


On Wed, 2009-10-28 at 22:54 -0500, Tony Guan wrote:
> Hi,
> 
> 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.
> 
> 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?

I think the easiest solution would be to use JVMTI, but it seems you
really want to do this in the VM.  The method you are searching for is
JVM_StartThread, this is where all Java threads are created.

-- Christian



More information about the hotspot-dev mailing list