Hi all ~ I have a problem that is too boring at times Sometimes when I exit my program, Then some thread is running in the Linux system, after leaving the main loop it will cause the accident. Is there any way that can kill all the threads when I leave the main loop?
This will greatly help you specify the library threading of your programming language and options.
The usual way of controlling this type of situation (the parent is for the thread, unless the children wait until the completion of the completion) call the function given by the library Generally, join or wait . For example, pthread provides you. If you increase the processes through the fork, then you should wait or wait, to stop the parents till the child is complete - try waiting for the man or take a look. In this way you can inform your children that you are going to get out in normal ways, until they wrap and do not end, then mainly exit the main loop. Does this help? If you want to actively kill the children's thread, then there are definitely options (such as pthread_kill for pthreads, for example). This is the method of synchronizing termination with at least cruel ways.
Comments
Post a Comment