I happened to read a sample Semaphore class, as shown below: msdn: https://msdn.microsoft.com/en-us/library/system.threading.semaphore%28v=vs.110%29.aspx
This is a console application, however, something confused me that child threads can even work with the outputs of the main thread.
From my understanding, when the main thread / process terminates, all child threads will be stopped, so we usually signal and expect the child threads to end before the main thread stops. Am I mistaken, or was the behavior changed in .net due to the link?
If you want the child thread to be interrupted when the parent thread terminates, it must be set as the background thread.
t.IsBackground = true; t.Start(i);
Otherwise, all foreground threads terminate before the process is complete.