Am 08.08.2012 20:26, schrieb Sean Kelly:
On Aug 8, 2012, at 8:33 AM, David <d...@dav1d.de> wrote:

Yes, but remember that the main thread doesn't die the moment the app's main() 
function returns.  There's some runtime shutdown code that's run first.  See 
druntime/rt/dmain2.d.

So in my case, the main thread hangs up in the runtime? great …

C/C++ works exactly the same way.  When a C/C++ app's main() function exits, 
various cleanup tasks are run before the process itself terminates.  Dtors of 
static objects are run, exit hooks are called, etc.  In effect, all kernel 
threads are daemon threads, and D provides the option to get this behavior when 
it's necessary.  But if you have a daemon thread and want it to shutdown 
cleanly you need to take steps to do so.

I suppose it's worth noting that if you use std.concurrency, this is all taken 
care of for you.  Any thread spawned by the main thread will automatically get 
an OwnerTerminated or LinkTerminated message as soon as that app's main() 
routine exits, so the next time they do a receive() an exception will be thrown 
and they'll terminate cleanly.  Are you sure you need to use core.thread here?

But I don't need the funtionallity of std.concurrency, should I use it anyways?

Reply via email to