I believe that you want to exit the workflow by signaling from the main thread.
Inside AcceptLoop instead of looping endlessly on the loop, you can set the condition through your main thread, you will have to use some synchronization for this variable. After the variable is set from the main thread, the AcceptLoop worker thread AcceptLoop out and you can call pthread_exit .
if you want your main thread to wait for a child thread to exit, you can use pthread_join to do this.
In general, a child thread can exit from three conditions:
- call
pthread_exit . - call
pthread_cancel . - The stream function is returned.
source share