I have an application which does some socket communication with some hardwares.
Assume for the particular hardware i have an object and this object initiates a thread which listens on a particular port number say 5001 infinitely until a connection is established.
Now if i delete this obect is there anyway by which i can ensure that the thread that is listening on port number 5001 infinitely also gets destroyed.
So the problem is whenever a new object for the same device is created the old thread does not get destroyed and hence there are thread leaks.
In Windows you could use WaitForSingleObject function to check whether thread exited (you can pass thread’s handle to is as an argument). And you probably want to create event which will initiate thread’s exit.