Consider the following example:
#include #include #include #include #include
Just use a semaphore, call sem_timedwait instead of usleep, and call sem_post before calling join
usleep
join