Solved

runFinalizersOnExit

Posted on 1998-01-19
5
207 Views
Last Modified: 2012-06-27
Is there anyway to hardwire runFinalizersOnExit
into a class?

Can you make an object that absolutely will run its
its finalize method?  If you can't insure it how do
you note it in the javadoc page.  Is there a standard
BEWARE gif I haven't seen?  Is there a compiler way to
change the default of not running finalizers.  (Does
java have a "pragma" way of controlling the compiler?)
Oh, just questions questions questions.

Comments only for a few days unless your believe your
answer is truly a definitive.
0
Comment
Question by:hank1
  • 3
  • 2
5 Comments
 

Expert Comment

by:rjg2000
ID: 1232383
To the best of my knowledge.

not as such, you can call Runtime.runFinalizersOnExit(true) to force the VM to run the finalizers before collecting the object but there is not guarentee that this will be done immediately.  (It will be done at the time the object is actually freed which may be alot later than when thre reference was lost.  I belive you can force unreference objects to run their finalizers by calling Runtime.runFinalization().  There is no way to force this behaviour without user code.

The way I would approach this is if the finalizer is so important then I would explictly call your own finaliztion method when you throw the object away.  (you imply that you really need the locked resource back and this thus guarantees it).

0
 
LVL 1

Author Comment

by:hank1
ID: 1232384
Running a program normally allows runFinalizersOnExit(true)
to run the finalize methods.  'break'ing out of a program
defeats it.  Anyway to 'capture' this
abnormal program abort and let runFinalizersOnExit()
do it thing?
0
 

Expert Comment

by:rjg2000
ID: 1232385
Not to the best of my knowledge,

If it is really important to do this clean up you will have to do
the house keeping yourself.

If you are talking about breaking out if a program by an execption you can catch this using

try
{
      ..program
}
catch(Throwable t)
{
      cleanUp();
}
}
0
 
LVL 1

Author Comment

by:hank1
ID: 1232386
Ah yes, so right.  Just capture the exception ...  Dahhhh
Thanks.  Plop an answer in here and I'll give rjg2000 the points
PS - You ready for 1999 - 2000 xsistion ( which is still the
20th century by-the-way)
0
 

Accepted Solution

by:
rjg2000 earned 50 total points
ID: 1232387
Here it is,

Yes, I'm year 2000 complient but only cos all my normal aliases are already used.  Which is strange cos my name and normal username are quite unusual.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Application launch issue with Apache Tomcat 5 64
egit plugin on eclipse 8 82
CSV file parsing thru Java 13 34
Crystal Reports Licensing Questions 4 34
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question