At 3:06 PM -0600 11/18/99, Craig R. McClanahan wrote:
>David Chisholm wrote:
>
> > [ Deleted Q&A about using threads to keep servlets from being unloaded. ]
>
>In the 2.1 and 2.2 servlet APIs, there is no longer any legal way for an
>application-level object (servlet or JavaBean) to acquire a reference to
>another
>servlet instance. Therefore, the server can guarantee that there are no
>dangling references to the servlet instance when it is unloaded, as long as
>it
>manages its own references correctly.
It seems to me that there's a little bit more to it than this. After
all, in my servlet's methods I have full access to the instance via
the "this" handle, so it's quite possible for me to create a
reference to it from some other class. Granted, it's a perversion of
the servlet spec for me to do this, but it can be done.
I think the distinction that may be missing here is that unloading a
servlet and garbage collecting it are two different and not
necessarily related issues. The servlet container can unload the
servlet after some period of inactivity, but if there's still a
reference to that servlet somewhere, it will not be garbage collected.
(On the other hand, the servlet container does manage its own
references to the "active" servlet instances, so it is certainly the
case that a servlet will not be garbage collected until it has been
unloaded.)
Returning to the original question, then, storing a reference to a
servlet in a thread could very well keep it from being garbage
collected, but has no influence over whether or not it will be
unloaded.
- Mark A. Kolb Staff Engineer
[EMAIL PROTECTED] Tivoli Systems Inc.
http://www.cross-site.com (512) 436-1955
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html