Re: How Stop Worker Thread if Owner Thread is Finished?

2020-10-27 Thread Marcone via Digitalmars-d-learn
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

Re: How Stop Worker Thread if Owner Thread is Finished?

2020-10-27 Thread Rene Zwanenburg via Digitalmars-d-learn
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

Re: How Stop Worker Thread if Owner Thread is Finished?

2020-10-27 Thread Marcone via Digitalmars-d-learn
I want to use isDaemon to automatic stop worker thread if ownner thread is finished

Re: How Stop Worker Thread if Owner Thread is Finished?

2020-10-27 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 08:33:36 UTC, Johann Lermer wrote: or you could use the fact, that receiveTimeout throws an exception, when main ends (although I don't know if this is the intended behaviour; the manual just says that it throws an exception when the sending thread was

Re: How Stop Worker Thread if Owner Thread is Finished?

2020-10-27 Thread Johann Lermer via Digitalmars-d-learn
You could tell your thread via a shared variable that main has ended: import std.stdio; import std.concurrency; import core.thread; shared bool end = false; void thread () { for (;;) { Thread.sleep (500.msecs); synchronized {

Re: How Stop Worker Thread if Owner Thread is Finished?

2020-10-27 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 00:46:48 UTC, Marcone wrote: Because when the main thread is completed the worker thread continues to run. Please provide a code example. It's much easier to reason about. Are you creating a thread from a thread and want the 2nd spawned thread to be terminated

How Stop Worker Thread if Owner Thread is Finished?

2020-10-26 Thread Marcone via Digitalmars-d-learn
Because when the main thread is completed the worker thread continues to run.