aspose file tools
The moose likes Java in General and the fly likes Finalize method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Finalize method" Watch "Finalize method" New topic
Author

Finalize method

Hs Raveendran
Greenhorn

Joined: Feb 05, 2010
Posts: 23

Is it possible to skip the execution of finalize method for a given object.
Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
No, it will always run. But you can include code in finalize that will recognize
the situation you are concerned about and take appropriate action.

Jim ... ...


BEE MBA PMP SCJP-6
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19232

Jim Hoglund wrote:No, it will always run.

Not necessarily. The JVM may exit before finalize() will be called. The only thing that can be said about finalize() is that it is called at most once for each instance and if it will be invoked this will occur before the object is garbage collected.

But programmers have no control over when it will or will not be called.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Finalize method
 
Similar Threads
Gc question
why finalize() can't be defined as private?
difference between finally and finalize()
Finalization Method
finalize