Program exiting from thread with infinite loop

Chris M. chrismohrfeld at
Fri Jan 19 17:46:58 UTC 2018

On Friday, 19 January 2018 at 17:17:28 UTC, Adam D. Ruppe wrote:
> On Friday, 19 January 2018 at 17:05:44 UTC, Chris M. wrote:
>> However when I try to spawn it in another thread it runs the 
>> function and then ends once it's done, like it's ignoring the 
>> while(true).
> It is probably terminating the child threads when the main one 
> ends. Might help to have the main wait until the child dies too.

I tried putting an infinite loop inside main() as well, didn't 
seem to help. I'm guessing there's probably a better way to make 
the main thread wait? I'm pretty new to threads and whatnot.

> But why are you putting it in a thread anyway? If the main is 
> doing nothing than just waiting, might as well just keep the 
> logic in there.

It'll be doing other things, this is just the first thing I've 

More information about the Digitalmars-d-learn mailing list