On Tuesday, 27 October 2020 at 12:16:01 UTC, Rene Zwanenburg
wrote:
On Tuesday, 27 October 2020 at 11:36:42 UTC, Marcone wrote:
I want to use isDaemon to automatic stop worker thread if
ownner thread is finished
Terminating threads without properly unwinding the stack is
generally a very bad idea. Most importantly the destructors of
stucts on the stack won't run which can cause problems like
locks not being released.
This isn't specific to D either. For example Raymond Chen
writes about the TerminateThread function in Windows here:
https://devblogs.microsoft.com/oldnewthing/20150814-00/?p=91811
You should signal the thread somehow that it's time to stop
working
isDaemon: A daemon thread is automatically terminated when all
non-daemon threads have terminated.