I'm not sure how is it done in Win32, but in .NET there is a IsBackground flag on a thread. Process dies when all its non-background threads exit.
http://msdn.microsoft.com/en-us/library/h339syd0.aspx
EDIT: It seems that in win32 the process does indeed die when the last thread exits. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms68...
Re:A Modern Guide to Threads
by dbattaglia on Friday December 02, 2011 @07:59AM
(#3303816)
Raymond Chen has a pretty good blog post on this:
http://blogs.msdn.com/b/oldnewthing/archive/2010/08/27/10054...
Basically, Win32 wants all threads to die out before the process exits, but the C runtime will exit out the process for you when your "main" thread dies.
This is true on Unix/Linux. I believe this is not true on Windows. (I'm not a Windows dev, so feel free to enlighten me if I am wrong.)
Everything else in the article seemed pretty OS-independent.