Assuming you have other threads running apart from main, you can use use a sem_wait
(semaphore initialized to 0) in main()
and then from your thread you can call sem_post
whenever you want main()
to run.
Read about semaphore and usage:
6
solved How to suspend and resume a Process and Thread in C++ [closed]