>>> Gokul Singh <[EMAIL PROTECTED]> 04-Jun-01 10:46:48 AM >>>
>The finalize method is not guaranteed to be called by the JVM
>as per the JVM specs.
That's not true. There are two issues:
1. some VMs don't implement finalization at all. They're not real
java VMs and I would advise against using them for serious work.
2. finalization doesn't occur when the reference becomes elligible
for GC but only just before the GC actually occurs. In some VMs this
could mean that it occurs hours after the reference got nulled, or
never if the VM doesn't run out of memory.
Here's the bit of the spec:
"The Java programming language does not specify how
soon a finalizer will be invoked, except to say that it will
happen before the storage for the object is reused."
>Any code which depends on the finalization of the class
>may yield inconsistent results in different scenarios.
Not so. For what I was describing the finalization not being run
wouldn't cause a problem. The finalization was being used to remove
the logger class from it's maintenance thread and kill the maintenance
thread if necessary.
Given my design some valid VM sessions will never cause the
finalization to be run because memory never needs to be reclaimed. But
I've taken account of that by stating that the maintenance thread be a
daemon. It will die when the VM dies. Finalization will solve resource
issues during the running of the machine.
This is like many other issues with Java: using some features can
result in bad practice, but it can also result in well defined, safe,
usable code.
Nic Ferrier
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html