I have many joinable threads that at some point need to all stop. The threads are pthread, but are created through RTAI's user-space interface (never mind the RTAI though).
For each thread I have a variable that I can set to tell them to quit. So what I do is:
- set that variable for each thread so that they stop
- Wait at most one second
- join the threads
Now the thing is, since I am using RTAI, which uses a kernel-space buddy thread to the work for me, if something goes wrong, the thread may go unresponsive (It has never happened, but I have to be careful just in case something DOES go wrong). In such a case, I just kill the thread.
So, my question is, once you have a thread that is killed, should you join
on it or not?