The Artima Developer Community
Sponsored Link

Legacy Design Forum
Finalization and Cleanup



This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


destructor in c++

Posted by mueez uddin khan on November 30, 2001 at 5:52 AM

> The trick to release non-memory resources in a destructor in C++
> seems not to apply anymore in Java, because garbage collection
> and finalization is not as controlled. Do you agree? Of course,
> may be someone could argue that it has never been an excellent
> idea in C++ to do so, but it is cleaner because C++ does not
> have a finally clause.

> Given the behavior in Java, we almost always have to provide a
> seperate method to release resources, and make sure that the
> method is called at the right time instead of relying on the
> finalizer to do so.

> It also seems that we almost always want to call System.runFinalizersOnExit(true) such that objects will be guaranteed to be finalized no matter how the program
> ends. Am I right?


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us