aspose file tools*
The moose likes Beginning Java and the fly likes Garbage collection will be triggered and finalize method will be called ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Garbage collection will be triggered and finalize method will be called ?" Watch "Garbage collection will be triggered and finalize method will be called ?" New topic
Author

Garbage collection will be triggered and finalize method will be called ?

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
I have some code in finalize method and assume that the object always in use and never become eligible for garbage collection ,now if the JVM closes then what what wll happen
Garbage collection will be triggered and finalize method will be called ?
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3378
    
    9
No. When the JVM closes, that's that. Nothing happens any more.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

You can try to use Runtime.getRumtime().addShutdownHook(...) but that's also not guaranteed to run if the JVM exits abruptly.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage collection will be triggered and finalize method will be called ?
 
Similar Threads
Quick Q concerning GC
finalize() method doubt........
Garbage Collection Problem
finalize......
Garbage Collection