Stopping a thread.
Posted on 2003-12-03
I have a function to allow thread creation and I use the following to kick of my threaded function :
pthread_create(&pThread, NULL, (void *)MonitorThread, NULL);
with my thread function being :
void *AppPing::MonitorThread(void *)
Now the creation works and it starts sending infor out of the serial port ttyS0 and reveiving info back, displaying the data sent out / received.
I have another function which disables the thread by setting a static bool. The thread checks this and if it is true, disables the thread by using the
Now this seems ok but if I enable the thread again I get a burst of activity on the serial port as if the thread never stopped sending info out of the serial port.
Am I killing the thread correctly? I fear not!