Do not join the stream, if not delete for all memory, you are new . It can be harmless, or it can be a bad habit.
A thread that you did not synchronize is in an unknown execution state. If it is a file write stream, it may be halfway through the file write, and then the application terminates. If this is a network communication stream, it could be halfway through a handshake.
The disadvantage of combining each thread is that one of them got into a bad state and is blocked, your application may freeze.
In general, you should try to send a message to your outstanding threads in order to tell them to go out and get out. Then you need to wait a little while for them to finish or otherwise answer that they know how to die, and then turn off the application. Now, before this, you must indicate that your program is no longer open for business - keep the windows of the graphical user interface, respond to requests from other processes that you are completing, etc. - therefore, if it takes longer than expected, the user is not worried. Finally, if everything goes wrong - if the threads refuse to respond to your request that they are closing, and you refuse them, then you should also log errors, so you can fix what might be a symptom of a more serious problem.
The last time a workflow hung unexpectedly, I initially thought it was a problem with a network outage and a timeout error. During a deeper check, this was due to the fact that before the shutdown synchronization, one of the used delete d objects was used: the undefined behavior, which turned out to be just like freezing in my propagation cases. If we were not careful, this error would be more difficult to track (now the right thing is to use a shared resource that we could not delete, but errors occur).
source share