BarZ:

Thank you very much for the enlightening comments...Yes they make a lot of
sense.

I do not want to watch the WorldCup...The Chinese team is such a shame...I
may cry if I watch them.


jeff

-----Original Message-----
From: Barzilai Spinak [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 06, 2002 12:04 PM
To: JDJList
Subject: [jdjlist] In response to the question about member classes


Every instance of an inner (or member) class is created from a previously
existing
instance of the enclosing class. (Unless the inner class is static, but
let's not
get into that)

Inside the instance of the inner class there exists a pointer to the
instance of
the outer class from which the inner instance was derived. 
We all know how within an instance method we can use "this" to refer to the
object
on which the context of this method invocation takes place. Well, from
within
the methods of an inner class we can use another reference called
"MyOuterClass.this"
which points to the instance of the outer class from which the inner
instance was derived.

All this to show that, even if you think you lost all your references to the
outer object
and it's going to be garbage collected, it won't until all the inner objects
derived from
it have become unreachable. The inner objects only have meaning with respect
to the outer
object. That's why the outer object is not collected; it's still reachable
from your inner
objects.

This also has a hidden problem. Let's say your inner object is also a thread
and it's
blocked waiting for something or other... and you lose references to both
the outer
and inner object... they won't be collected because the inner object which
is a thread
is still alive, and it points to the outer object... but they both have
become
unreachable from your code and the inner object(thread) probably can't be
awaken or killed.
Memory/resource leak here?  I'd like someone else's view on this matter.
Make good use of your finally's!!!!!

I hope this makes sense. I haven't gotten much sleep watching the World Cup
games.

BarZ

To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

Reply via email to