On Wed, 25 May 2011 11:52:14 -0400, Steven Schveighoffer <schvei...@yahoo.com> wrote:

On Wed, 25 May 2011 11:35:51 -0400, Matthew Ong <on...@yahoo.com> wrote:

On 5/25/2011 11:13 PM, Steven Schveighoffer wrote:
http://www.digitalmars.com/d/2.0/class.html#StaticDestructor

-Steve

Static Destructor maybe executed when the class is being unloaded GC?
Because this is a class level. It is more like the application level exit and such.

This is *exactly* what static destructors do.

"A static destructor gets called on program termination"

Actually, that description is inaccurate for non-shared static dtors, someone should fix that.

That is not really the same as:
http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Runtime.html#addShutdownHook%28java.lang.Thread%29

If you want a static dtor that runs on every thread shutdown, use a normal static dtor. If you want one that runs on the entire application shutdown, use a shared static dtor.

I should clarify that when I wrote this, I thought the description was from the module.html file, not the class.html file. Ali pointed out the bug in the web site. So I didn't get why you were talking about classes, sorry :)

Class and module static ctor/dtors should be exactly what you are looking for.

-Steve

Reply via email to