I have thread which sleeps for a long time, then wakes up to do something, then sleep again, like this:
while(some_condition) { // do something sleep(100
As an alternative to sleep, you could use pthread_cond_timedwait with a 1000 ms timeout. Then when you want to exit, signal the condition variable.
sleep
This is similar to how you might do this in C#/Java using wait and notify.