Any application shutdown hooks?
Steven Schveighoffer
schveiguy at yahoo.com
Wed May 25 08:52:14 PDT 2011
On Wed, 25 May 2011 11:35:51 -0400, Matthew Ong <ongbp at 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.
-Steve
More information about the Digitalmars-d-learn
mailing list