I think you will be able to give a better solution when you know what the problem is . See I have three threads on a server like appication
1) -which waits for an incoming connection and accepts it
2) -Then saving the client's log in details
3) -One for listening to a port for incoming pakcets .
So I need to be able to run then till the application quits
Thanks
You can run those threads in infinite loop. When application quits, those threads will stop anyway.
Or even better, if you have a way to stop application(say a thread waiting for exit command etc.), then you can send message to those threads. The message can be as simple as a boolean variable. So once exit command is received, all threads (which are running in a loop and checking if exit command is received) will finish current task, make cleanup (close log file descriptor, close sockets etc.) and break the loop. Join those threads in main and exit.