Daemon Threads

David d at dav1d.de
Tue Aug 7 16:01:27 PDT 2012


> Daemon threads will keep running until the process terminates.Forcibly halting them any earlier risks leaving mutexes they hold in a 
locked state, etc, which could break shutdown and hang the app. 
Typically, you'll want to have a shared module dtor communicate to any 
daemon threads that it's time for them to halt, and block until a 
response is received if you want to ensure a clean shutdown.

Ok, so it's not like e.g. in Python, if the main thread terminates, all 
daemons die and the process exits?

Let's say I have a static shared dtor, which communicates to all 
daemons, hey you have to shutdown, now! But what happens if an exception 
is thrown, will the dtor still be called? And how would you communicate 
with the different threads?


More information about the Digitalmars-d-learn mailing list