Suppose I declare
pthread_t clear_thread;
and then
pthread_create(&clear_thread, &detach, clear_message, this);
the thread is supposed to go away, perform the service it is intended to procide, and then kill itself.
A little while later, I require this service again, so I say
pthread_create(&clear_thread, &detach, clear_message, this);
Now if, whether by accident or design, the first thread is still running, what is supposed to happen? The man pages seem to be silent on this issue (one would have hoped that creating a new thread on an already running identifier would return an error, but it seems not to be so).
So, are there now two threads running? and if I try to do a pthread_kill on it which thread (or both?) gets killed?
And, for that matter, is there any way to tell whether a thread that I have created is still running? Or do I have to declare a variable to keep track of that myself?
I suspect that the answer is that I have made a programming blunder by allowing this situation to arise, but it is an easy mistake to make, especially if you did not foresee the necessity to demand this service frequently (I got into this mess because my progma ran amok and started demanding service continuously, and eventually I think I got into some deadlock). But if that is the answer, then I suspect it is a bug in the design of the pthread system - or is it a feature?
For the record, I am trying to put messages up on an LCD, and this thread is created to take them down again after 30 seconds, or when the user acknowledges them, or whatever, and there are associated threads for putting the backlight on, and turning it off after a while.