Daemon Threads

Sean Kelly sean at invisibleduck.org
Tue Aug 7 12:38:36 PDT 2012


On Aug 7, 2012, at 9:36 AM, David <d at dav1d.de> wrote:

> I have a threaded connection:
> ...
> Since this is a daemon thread, I'd expect it to stop/terminate when the main thread stops. This is not the case (it keeps running), is this a known bug and how can I workaround this?

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.


More information about the Digitalmars-d-learn mailing list