classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Memory leak in java.lang.Thread ?


From: Jeroen Frijters
Subject: RE: Memory leak in java.lang.Thread ?
Date: Fri, 10 Dec 2004 09:50:53 +0100

David Holmes wrote:
> Sun "fixed" this in Java 5.0. However, while the obvious fix 
> is to clarify what "active" thread means for ThreadGroup, they
> didn't update the spec but simply decided they could interpret
> it how they wanted. So I can't tell you exactly what they did
> because it is implementation detail.

Running:

Thread t = new Thread("MyThread");
System.out.println(t.getThreadGroup());
Thread.currentThread().getThreadGroup().list();

on JDK 1.5 shows that the unstarted Thread considers itself to be part
of the ThreadGroup but not vice versa. 

So it appears they went for the "obvious" solution of only adding the
Thread to the ThreadGroup when it is started.

> I will note that you also have to consider what it means for 
> a ThreadGroup to be "empty" for daemon-ness and destroy purposes.

Thanks for the hint :-) So this means that we'll need a count in
ThreadGroup of unstarted threads.

I've attached my first stab at implementing this.

Regards,
Jeroen

Attachment: Thread.patch.txt
Description: Thread.patch.txt


reply via email to

[Prev in Thread] Current Thread [Next in Thread]