I have a process that starts several threads that do some things, listen on some ports, etc.
After starting all threads, the main thread currently goes into an endless loop:
This is something like:
int main()
{
while (true)
{
sleep(1000);
}
}
Optional sleepensures that the main thread is not powered by the processor.
Is this approach appropriate? Is there an industry standard for how a process is supported by alivet? Thank.
EDIT: some explanation:
- threads are listeners, therefore
joinor WaitForSingleObjectnot an option. Normally I could use the connection here, but the threads are started by the third client library, and I do not control them. - Performing some processing in the main thread does not make sense from a design point of view.