• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

finalize()

 
Ranch Hand
Posts: 579
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I Found one statement like
"The finalize() method may resurrect the object upon which it has been invoked."
How is it possible .please explain.......
Thanx
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


"The finalize() method may resurrect the object upon which it has been invoked."



hi

overide the finalize method in your class.
In that method collect the object to the reference.
Since reference is there object will not be collected by GC
but only once we can prevent in this way because finalize method will be called only one for an object.

hope it clears
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is from some pdf file. It may help you.

There are a couple of concepts concerning finalize() :

1. For any given object, finalize() will be called only once by the
garbage collector.
2. Calling finalize() can actually result in saving an object from deletion.

First of all, finalize() is a method, and any code that you can put into a normal method you can put into finalize(). For example, in the finalize() method you could write code that passes a reference to the object in question back to another object, effectively 'uneligiblizing' the object for garbage collection. If at some point later on this same object becomes eligible for garbage collection again, the garbage collector can still process this object and delete it.

The garbage collector, however,will remember that, for this object, finalize() already ran, and it will not run finalize() again.
 
agrah upadhyay
Ranch Hand
Posts: 579
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Lalitha,it appealed me!
 
reply
    Bookmark Topic Watch Topic
  • New Topic